点击发送按钮强制关闭应用

时间:2015-05-31 09:04:42

标签: php android android-asynctask

我正在开发一个Android应用程序,它连接到远程MySQL数据库,并在该服务器上托管PHP脚本。我的Android应用程序是用于注册目的。它从android传递到MySQL数据库的两个字符串。当我写它并安装在移动应用程序在该注册表单中单击发送按钮后强制关闭。错误如下。任何人帮我解决

  

05-31 13:17:55.758 13875-13978 /? E / AndroidRuntime?致命异常:AsyncTask#2           处理:com.example.naveen.e_complaint,PID:13875           java.lang.RuntimeException:执行doInBackground()时发生错误                   在android.os.AsyncTask $ 3.done(AsyncTask.java:304)                   在java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)                   at java.util.concurrent.FutureTask.setException(FutureTask.java:222)                   在java.util.concurrent.FutureTask.run(FutureTask.java:242)                   在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)                   at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)                   在java.lang.Thread.run(Thread.java:818)            引起:java.lang.NullPointerException:尝试在空对象引用上调用虚方法'android.text.Editable android.widget.EditText.getText()'                   at com.example.naveen.e_complaint.childprotection $ CreateNewProduct.doInBackground(childprotection.java:83)                   at com.example.naveen.e_complaint.childprotection $ CreateNewProduct.doInBackground(childprotection.java:63)                   在android.os.AsyncTask $ 2.call(AsyncTask.java:292)                   在java.util.concurrent.FutureTask.run(FutureTask.java:237)       在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)       在java.lang.Thread.run(Thread.java:818)       05-31 13:17:58.738 13875-13875 /? E /窗口管理器? android.view.WindowLeaked:Activity com.example.naveen.e_complaint.childprotection泄露了窗口com.android.internal.policy.impl.PhoneWindow $ DecorView {15abb8ab VE .... R ...... D 0,0 -456,174}最初是在这里添加的                   在android.view.ViewRootImpl。(ViewRootImpl.java:363)                   在android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:271)                   在android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)                   在android.app.Dialog.show(Dialog.java:298)                   at com.example.naveen.e_complaint.childprotection $ CreateNewProduct.onPreExecute(childprotection.java:75)                   在android.os.AsyncTask.executeOnExecutor(AsyncTask.java:591)                   在android.os.AsyncTask.execute(AsyncTask.java:539)                   at com.example.naveen.e_complaint.childprotection $ 1.onClick(childprotection.java:54)                   在android.view.View.performClick(View.java:4780)                   在android.view.View $ PerformClick.run(View.java:19866)                   在android.os.Handler.handleCallback(Handler.java:739)                   在android.os.Handler.dispatchMessage(Handler.java:95)                   在android.os.Looper.loop(Looper.java:135)                   在android.app.ActivityThread.main(ActivityThread.java:5257)                   at java.lang.reflect.Method.invoke(Native Method)                   在java.lang.reflect.Method.invoke(Method.java:372)                   在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:903)                   在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)       05-31 13:18:00.991 1246-1272 / system_process E / JavaBinder? !失败的粘合剂交易!       05-31 13:18:01.006 1246-1330 / system_process E / InputDispatcher? channel'23c97e57 com.example.naveen.e_complaint / com.example.naveen.e_complaint.MainActivity(server)'〜频道无法恢复,将被丢弃!       05-31 13:18:01.016 1246-1330 / system_process E / InputDispatcher? channel'312e3255 com.example.naveen.e_complaint / com.example.naveen.e_complaint.childprotection(server)'〜频道无法恢复,将被丢弃!       05-31 13:18:01.019 1246-1330 / system_process E / InputDispatcher? channel'8f330dc com.example.naveen.e_complaint / com.example.naveen.e_complaint.DepartmentsList(server)'〜频道无法恢复,将被处置!

1 个答案:

答案 0 :(得分:0)

您将遇到的另一个错误是您尝试在doInBackground()中显示的Toast - 异步任务在非UI线程上运行,并且无法执行UI操作。