JSON解析问题未解决

时间:2012-12-31 10:02:13

标签: java php android mysql json

我的LogCat错误是:

    12-31 14:45:14.920: E/WindowManager(3420): Activity com.example.visit.record.My_Task has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4054ed00 that was originally added here
    12-31 14:45:14.920: E/WindowManager(3420): android.view.WindowLeaked: Activity com.example.visit.record.My_Task has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4054ed00 that was originally added here
    12-31 14:45:14.920: E/WindowManager(3420):  at android.view.ViewRoot.<init>(ViewRoot.java:277)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.view.Window$LocalWindowManager.addView(Window.java:433)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.Dialog.show(Dialog.java:288)
    12-31 14:45:14.920: E/WindowManager(3420):  at com.example.visit.record.My_Task$GetTaskDetails.onPreExecute(My_Task.java:137)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.os.AsyncTask.execute(AsyncTask.java:391)
    12-31 14:45:14.920: E/WindowManager(3420):  at com.example.visit.record.My_Task.onCreate(My_Task.java:105)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.ActivityThread.access$1500(ActivityThread.java:132)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.os.Handler.dispatchMessage(Handler.java:99)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.os.Looper.loop(Looper.java:143)
    12-31 14:45:14.920: E/WindowManager(3420):  at android.app.ActivityThread.main(ActivityThread.java:4268)
    12-31 14:45:14.920: E/WindowManager(3420):  at java.lang.reflect.Method.invokeNative(Native Method)
    12-31 14:45:14.920: E/WindowManager(3420):  at java.lang.reflect.Method.invoke(Method.java:507)
    12-31 14:45:14.920: E/WindowManager(3420):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    12-31 14:45:14.920: E/WindowManager(3420):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    12-31 14:45:14.920: E/WindowManager(3420):  at dalvik.system.NativeStart.main(Native Method)
12-31 14:54:22.360: E/AndroidRuntime(4423):     at com.example.visit.record.My_Task$GetTaskDetails.doInBackground(My_Task.java:163)
12-31 15:10:51.470: W/System.err(6457):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
12-31 15:10:51.470: W/System.err(6457):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
12-31 15:10:51.470: W/System.err(6457):     at java.lang.Thread.run(Thread.java:1027)
12-31 15:10:51.480: E/Buffer Error(6457): Error converting result java.lang.NullPointerException
12-31 15:10:51.480: E/JSON Parser(6457): Error parsing data org.json.JSONException: End of input at character 0 of 
12-31 15:10:51.480: W/dalvikvm(6457): threadid=9: thread exiting with uncaught exception (group=0x400205a0)
12-31 15:10:51.490: E/AndroidRuntime(6457): FATAL EXCEPTION: AsyncTask #1
12-31 15:10:51.490: E/AndroidRuntime(6457): java.lang.RuntimeException: An error occured while executing doInBackground()
12-31 15:10:51.490: E/AndroidRuntime(6457):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
12-31 15:10:51.490: E/AndroidRuntime(6457):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
12-31 15:10:51.490: E/AndroidRuntime(6457):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
12-31 15:10:51.490: E/AndroidRuntime(6457):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
12-31 15:10:51.490: E/AndroidRuntime(6457):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
12-31 15:10:51.490: E/AndroidRuntime(6457):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)

我在getTaskDetail类的Preexecute对话框中的 dialog.show(); 上收到错误。并在 Log.d(“单一任务详细信息”,json.toString()); 上显示错误,并在新GetTaskDetails()上遇到错误.execute();

请指导为什么它不能从我的php应用程序数据库中获取值。并通过生成“强制关闭”错误意外停止。请指导哪里出错了。我想使用JSONParsing

从MySql获取数据到android

3 个答案:

答案 0 :(得分:2)

我认为您在模拟器中运行时在url中的问题会将URL更改为

private static final String url_read_mytask = "http://10.0.2.2/evisiting_records/read_mytask.php";

private static final String url_update_mytask = "http://10.0.2.2/evisiting_records/update_mytask.php"

答案 1 :(得分:0)

它没有问题json它接缝你试图与后台线程的ui线程交互。 看一下: Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46368a28 that was originally added here

答案 2 :(得分:0)

我认为你的JSON存在问题会导致泄漏窗口:

Error parsing data org.json.JSONException: End of input at character 0 of

您可以发布JSON(通过在浏览器中打开网址或CURL并复制内容)。 JSON似乎无效。