在果冻豆模拟器我的应用程序错误 [英] My App Error on Jelly Bean Simulator

查看:158
本文介绍了在果冻豆模拟器我的应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很抱歉,如果有这样的问题,
我只是想知道,我试图读取服务器上的文件.txt和我转换成int和
我有成功的,当我在升级Froyo模拟器尝试

i'm sorry if there is a question like this i just wanna know, i'm trying to read file .txt on server and i convert to int and i have succeed when i try on froyo simulator

这是我的code

final Context context = this;
TextView textServer, textApp;
final String textSource = "http://xxx/dev/android/androidversi.txt";

声明位置的.txt文件的

DECLARATION FOR LOCATION OF .txt file

URL textUrl;
String StringBuffer;
String stringText = "";

try {
    textUrl = new URL(textSource);
    BufferedReader bufferReader = new BufferedReader(new InputStreamReader(textUrl.openStream()));

    while ((StringBuffer = bufferReader.readLine()) != null) 
    {
        stringText += StringBuffer;
    }
    bufferReader.close();
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

code上面写明从服务器和.txt文件时,此code WHICE ARE Jelly Bean中的错误,因为我的Froyo ON尝试的正常运行。

CODE ABOVE READS .txt FILE FROM SERVER AND THIS CODE WHICE ARE ERRORS IN JELLY BEAN, BECAUSE I'VE TRIED ON FROYO IS RUNNING NORMALLY

PackageManager manager = getPackageManager();
PackageInfo info;
try {
    info = manager.getPackageInfo(getPackageName(), 0);
    int version = info.versionCode;

    if(Integer.parseInt(stringText)>version) // I'VE CONVERTED STRING FROM .txt TO INT SO THAT I CAN COMPARE IT WITH VERSION ON APP
    {
        // IF VERSION ON SERVER > VERSION APP THERE IS LINK TO DOWNLOAD HERE
    }
} catch (NameNotFoundException e){
    e.printStackTrace();
}

比较版本

请帮我:'(

推荐答案

它不过是网络上的主线程除外;只是包括

Its nothing but the Network on main thread exception; Just include

if (android.os.Build.VERSION.SDK_INT > 9) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
}

到code(在onCreate()方法),你会被罚款:)

to your code (in onCreate() method) and you'll be fine :)

这篇关于在果冻豆模拟器我的应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆