我正在为
JSONObject请求服务器,它包含一些ID的列表.这适用于
Android 4.2,但不适用于Android 2.3(已在Device和Emulator上测试过.)
原文链接:/json/443128.htmlJSONObject如下.
{"IdList":[{"id":"004502"},{"id":"S007901"},{"id":"041501"},{"id":"S139001"}]}
这适用于4.2,但在2.3中显示NullPointerException.
我的LogCat如下:
org.json.JSONException: Value Nullpointer of type java.lang.String cannot be converted to JSONObject 06-06 11:23:46.881: W/System.err(1820): at org.json.JSON.typeMismatch(JSON.java:107) 06-06 11:23:46.893: W/System.err(1820): at org.json.JSONObject.<init>(JSONObject.java:158) 06-06 11:23:46.893: W/System.err(1820): at org.json.JSONObject.<init>(JSONObject.java:171) 06-06 11:23:46.893: W/System.err(1820): at my.Site.serverInterface.executeHttpRequest(serverInterface.java:128) 06-06 11:23:46.893: W/System.err(1820): at my.Site.serverInterface.getAtmId(serverInterface.java:54) 06-06 11:23:46.901: W/System.err(1820): at my.Site.TrackLocation$AtmGetter.doInBackground(TrackLocation.java:379) 06-06 11:23:46.901: W/System.err(1820): at android.os.AsyncTask$2.call(AsyncTask.java:185) 06-06 11:23:46.901: W/System.err(1820): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) 06-06 11:23:46.901: W/System.err(1820): at java.util.concurrent.FutureTask.run(FutureTask.java:138) 06-06 11:23:46.901: W/System.err(1820): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) 06-06 11:23:46.901: W/System.err(1820): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 06-06 11:23:46.901: W/System.err(1820): at java.lang.Thread.run(Thread.java:1019) 06-06 11:23:46.901: I/System.out(1820): null 06-06 11:23:46.912: I/System.out(1820)://e 06-06 11:23:46.912: W/System.err(1820): java.lang.NullPointerException 06-06 11:23:46.912: W/System.err(1820): at my.Site.TrackLocation$AtmGetter.doInBackground(TrackLocation.java:384) 06-06 11:23:46.912: W/System.err(1820): at android.os.AsyncTask$2.call(AsyncTask.java:185) 06-06 11:23:46.912: W/System.err(1820): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) 06-06 11:23:46.912: W/System.err(1820): at java.util.concurrent.FutureTask.run(FutureTask.java:138) 06-06 11:23:46.912: W/System.err(1820): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) 06-06 11:23:46.912: W/System.err(1820): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 06-06 11:23:46.912: W/System.err(1820): at java.lang.Thread.run(Thread.java:1019) 06-06 11:23:46.921: W/dalvikvm(1820): threadid=10: thread exiting with uncaught exception (group=0xb60c84f0) 06-06 11:23:46.931: E/AndroidRuntime(1820): FATAL EXCEPTION: AsyncTask #3 06-06 11:23:46.931: E/AndroidRuntime(1820): java.lang.RuntimeException: An error occured while executing doInBackground() 06-06 11:23:46.931: E/AndroidRuntime(1820): at android.os.AsyncTask$3.done(AsyncTask.java:200) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.FutureTask.setException(FutureTask.java:125) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.FutureTask.run(FutureTask.java:138) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.lang.Thread.run(Thread.java:1019) 06-06 11:23:46.931: E/AndroidRuntime(1820): Caused by: java.lang.NullPointerException 06-06 11:23:46.931: E/AndroidRuntime(1820): at my.Site.TrackLocation$AtmGetter.doInBackground(TrackLocation.java:427) 06-06 11:23:46.931: E/AndroidRuntime(1820): at android.os.AsyncTask$2.call(AsyncTask.java:185) 06-06 11:23:46.931: E/AndroidRuntime(1820): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) 06-06 11:23:46.931: E/AndroidRuntime(1820): ... 4 more