我最近工作的應用程序連接和解析從web服務器的數據到Android設備,測試froyo和薑餅,工作正常,但在ICS設備崩潰。至於用戶界面我使用gingebread對象,所以我認爲這不是問題。應用程序工作正常froyo和薑餅,但不是在ICS
即使在連接到Facebook之後,它在第一次運行時也能正常工作,但在獲取和解析收集的所有JSON數據的部分發生錯誤。
這裏是logcat的錯誤從設備直:
E/AndroidRuntime(25620): FATAL EXCEPTION: Thread-9660
E/AndroidRuntime(25620): java.lang.UnsupportedOperationException
E/AndroidRuntime(25620): at java.lang.Thread.stop(Thread.java:1076)
E/AndroidRuntime(25620): at java.lang.Thread.stop(Thread.java:1063)
E/AndroidRuntime(25620): at com.android.guestlist.SplashScreen$1.run(Spla
shScreen.java:89)
E/android.os.Debug(2090): [email protected] > dumpstate -k -t -n -z -d -o /data/log/d
umpstate_app_error
E/Launcher(18546): Error finding setting, default accessibility to not found: ac
cessibility_enabled
E/log_tag (25620): Error in http connection android.os.NetworkOnMainThreadExcept
ion
E/log_tag (25620): Error converting result java.lang.NullPointerException
E/log_tag (25620): Error parsing data org.json.JSONException: End of input at ch
aracter 0 of
E/log_tag (25620): Error in http connection android.os.NetworkOnMainThreadExcept
ion
E/log_tag (25620): Error converting result java.lang.NullPointerException
E/log_tag (25620): Error in http connection android.os.NetworkOnMainThreadExcept
ion
E/log_tag (25620): Error parsing data org.json.JSONException: End of input at ch
aracter 0 of
這是我的JSON解析器,因爲我認爲這是問題發生?呵呵,我創建的日誌甚至沒有出現在電話記錄嗯,我真的不能說,但這裏是代碼:
public void getDataFromWeb(String a, String b){
String result = "";
Log.v(TAG, "Name Value Pair a " + a);
Log.v(TAG, "Name Value Pair b " + b);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("a_param",a));
nameValuePairs.add(new BasicNameValuePair("b_param",b));
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://[mywebserviceshere].php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
Log.v(TAG, "connected");
}catch(Exception e){
Log.v(TAG, "run failed");
Log.e("log_tag", "Error in http connection "+e.toString());
}
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
sb = new StringBuilder();
String line = "0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
Log.v(TAG, "buffered read");
}catch(Exception e){
Log.v(TAG, "buffered error");
Log.e("log_tag", "Error converting result "+e.toString());
}
try{
Log.v(TAG, result);
JSONArray jArray = new JSONArray(result);
JSONObject json_data=null;
for(int i=0;i<jArray.length();i++){
Log.v(TAG, "loop start");
json_data = jArray.getJSONObject(i);
w.add(json_data.getString("w_data"));
x.add(json_data.getString("x_data"));
y.add(json_data.getString("y_data"));
z.add(json_data.getString("y_data"));
Log.v(TAG, "list added");
}
}catch(JSONException e){
w.add("0");
x.add("No Data");
y.add("No Data");
z.add("No Data");
Log.v(TAG, "rest failed");
Log.e("log_tag", "Error parsing data "+e.toString());
}
}
最後在這裏也正是它看起來像AVD:
這是ICS上的問題還是我必須修改我的一些代碼?
複製先生。感謝你的回答。現在將閱讀文檔。 – KaHeL 2012-08-14 06:24:53