android - How to avoid .IllegalStateException -
02-09 12:06:38.745: warn/dalvikvm(198): threadid=3: thread exiting uncaught exception (group=0x4001b188) 02-09 12:06:38.766: error/androidruntime(198): uncaught handler: thread main exiting due uncaught exception 02-09 12:06:39.415: debug/dalvikvm(198): gc freed 1522 objects / 308248 bytes in 400ms 02-09 12:06:39.574: error/androidruntime(198): java.lang.illegalstateexception: not execute method of activity 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view$1.onclick(view.java:2031) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.performclick(view.java:2364) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.ontouchevent(view.java:4179) 02-09 12:06:39.574: error/androidruntime(198): @ android.widget.textview.ontouchevent(textview.java:6541) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.dispatchtouchevent(view.java:3709) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1659) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1107) 02-09 12:06:39.574: error/androidruntime(198): @ android.app.activity.dispatchtouchevent(activity.java:2061) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1643) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewroot.handlemessage(viewroot.java:1691) 02-09 12:06:39.574: error/androidruntime(198): @ android.os.handler.dispatchmessage(handler.java:99) 02-09 12:06:39.574: error/androidruntime(198): @ android.os.looper.loop(looper.java:123) 02-09 12:06:39.574: error/androidruntime(198): @ android.app.activitythread.main(activitythread.java:4363) 02-09 12:06:39.574: error/androidruntime(198): @ java.lang.reflect.method.invokenative(native method) 02-09 12:06:39.574: error/androidruntime(198): @ java.lang.reflect.method.invoke(method.java:521) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) 02-09 12:06:39.574: error/androidruntime(198): @ dalvik.system.nativestart.main(native method) 02-09 12:06:39.574: error/androidruntime(198): caused by: java.lang.reflect.invocationtargetexception 02-09 12:06:39.574: error/androidruntime(198): @ com.ey.eyconnect.connect_ey.btnsaveactive(connect_ey.java:1734) 02-09 12:06:39.574: error/androidruntime(198): @ java.lang.reflect.method.invokenative(native method) 02-09 12:06:39.574: error/androidruntime(198): @ java.lang.reflect.method.invoke(method.java:521) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view$1.onclick(view.java:2026) 02-09 12:06:39.574: error/androidruntime(198): ... 22 more 02-09 12:06:39.574: error/androidruntime(198): caused by: java.lang.illegalstateexception: not execute method of activity 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view$1.onclick(view.java:2031) 02-09 12:06:39.574: error/androidruntime(198): @ android. view.view.performclick(view.java:2364) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.ontouchevent(view.java:4179) 02-09 12:06:39.574: error/androidruntime(198): @ android.widget.textview.ontouchevent(textview.java:6541) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.dispatchtouchevent(view.java:3709) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1659) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1107) 02-09 12:06:39.574: error/androidruntime(198): @ android.app.activity.dispatchtouchevent(activity.java:2061) 02-09 12:06:39.574: error/androidruntime(198): @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1643) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewroot.handlemessage(viewroot.java:1691) 02-09 12:06:39.574: error/androidruntime(198): @ android.os.handler.dispatchmessage(handler.java:99) 02-09 12:06:39.574: error/androidruntime(198): @ android.os.looper.loop(looper .java:123) 02-09 12:06:39.574: error/androidruntime(198): ... 26 more 02-09 12:06:39.574: error/androidruntime(198): caused by: java.lang.reflect.invocationtargetexception 02-09 12:06:39.574: error/androidruntime(198): @ com.ey.eyconnect.connect_ey.btnsaveactive(connect_ey.java:1734) 02-09 12:06:39.574: error/androidruntime(198): @ java.lang.reflect.method.invokenative(native method) 02-09 12:06:39.574: error/androidruntime(198): @ java.lang.reflect.method.invoke(method.java:521) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view$1.onclick(view.java:2026) 02-09 12:06:39.574: error/androidruntime(198): ... 42 more 02-09 12:06:39.574: error/androidruntime(198): caused by: java.lang.illegalstateexception: not execute method of activity 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view$1.onclick(view.java:2031) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.performclick(view.java:2364) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.ontouchevent(view.java:4179) 02-09 12:06:39.574: error/androidruntime(198): @ android.widget.textview.ontouchevent(textview.java:6541) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.view.dispatchtouchevent(view.java:3709) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:884) 02-09 12:06:39.574: error/androidruntime(198): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:
i need save number. when save 5-6 times exception throwing..
shown ***background.start(); looper.loop(); line*** background thread , method saving number : public void btnsave(view v) { // save button invoked db = eventsdata.getwritabledatabase(); edt = (edittext) this.findviewbyid(r.id.edteyconnect); edt1 = (edittext) this.findviewbyid(r.id.edtpass); string prevedt = edt.gettext().tostring(); string eyid = edt.gettext().tostring(); thread background = new thread(new runnable() { public void run() { boolean res = false; boolean stringres = false; db = eventsdata.getwritabledatabase(); string eyid = edt.gettext().tostring(); looper.prepare(); // ------------------------------------------------------------------------- try { charsequence char0 = "success"; charsequence char1 = edt2.gettext().tostring(); res = result.contains(char0); stringres = result.contains(char1); bundle bundle = new bundle(); bundle.putboolean("key1", res); bundle.putboolean("key2", stringres); bundle.putint("flag", 1); message message = new message(); message.setdata(bundle); handler.sendmessage(message); } catch (exception e) { contentvalues values = new contentvalues(); values.put(eventdatasqlhelper.status, stat); db.update(eventdatasqlhelper.table, values, "id = " + eyid, null); bundle bundle = new bundle(); bundle.putint("flag", 0); message message = new message(); message.setdata(bundle); } } }); // start background thread background.start(); looper.loop(); }
looks accessing ui elements within background thread, not allowed.
do want save in background on button click keep app responsive? try using asynctask
easier in opinion
Comments
Post a Comment