Android Fatal Exception main in AsyncTask class -
iam having code contain separated thread
import android.os.asynctask; import android.os.bundle; import android.app.activity; import android.app.progressdialog; import android.content.intent; public class profile_inner_tab extends activity { // progress dialog private progressdialog pdialog; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.profile_layout); new loadallproducts().execute(); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); } /** * background async task load product making http request * */ class loadallproducts extends asynctask<string, string, string> { int success; /** * before starting background thread show progress dialog * */ public loadallproducts(){ } @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(profile_inner_tab.this); pdialog.setmessage("checking email , password..."); pdialog.setindeterminate(false); pdialog.setcancelable(false); pdialog.show(); } /** * getting products url * */ protected string doinbackground(string... args) { // building parameters return null; } /** * pash tawaw bwni background task dialogaka labda * **/ protected void onpostexecute(string file_url) { // dismiss dialog after getting products pdialog.dismiss(); // updating ui background thread runonuithread(new runnable() { public void run() { } }); } } }
i have 2 level tab menus when use class within first level tab works fine when use in in second level tab crushes application exceptions
04-05 13:44:07.573: e/androidruntime(9725): fatal exception: main 04-05 13:44:07.573: e/androidruntime(9725): java.lang.runtimeexception: unable start activity componentinfo{com.example.univer_city/com.example.univer_city.profile}: java.lang.runtimeexception: unable start activity componentinfo{com.example.univer_city/com.example.univer_city.profile_inner_tab}: android.view.windowmanager$badtokenexception: unable add window -- token android.app.localactivitymanager$localactivityrecord@40e587e8 not valid; activity running? 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.startactivitynow(activitythread.java:2023) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.localactivitymanager.movetostate(localactivitymanager.java:135) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.localactivitymanager.startactivity(localactivitymanager.java:347) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabhost$intentcontentstrategy.getcontentview(tabhost.java:749) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabhost.setcurrenttab(tabhost.java:413) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabhost$2.ontabselectionchanged(tabhost.java:154) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabwidget$tabclicklistener.onclick(tabwidget.java:546) 04-05 13:44:07.573: e/androidruntime(9725): @ android.view.view.performclick(view.java:4204) 04-05 13:44:07.573: e/androidruntime(9725): @ android.view.view$performclick.run(view.java:17355) 04-05 13:44:07.573: e/androidruntime(9725): @ android.os.handler.handlecallback(handler.java:725) 04-05 13:44:07.573: e/androidruntime(9725): @ android.os.handler.dispatchmessage(handler.java:92) 04-05 13:44:07.573: e/androidruntime(9725): @ android.os.looper.loop(looper.java:137) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.main(activitythread.java:5041) 04-05 13:44:07.573: e/androidruntime(9725): @ java.lang.reflect.method.invokenative(native method) 04-05 13:44:07.573: e/androidruntime(9725): @ java.lang.reflect.method.invoke(method.java:511) 04-05 13:44:07.573: e/androidruntime(9725): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 04-05 13:44:07.573: e/androidruntime(9725): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 04-05 13:44:07.573: e/androidruntime(9725): @ dalvik.system.nativestart.main(native method) 04-05 13:44:07.573: e/androidruntime(9725): caused by: java.lang.runtimeexception: unable start activity componentinfo{com.example.univer_city/com.example.univer_city.profile_inner_tab}: android.view.windowmanager$badtokenexception: unable add window -- token android.app.localactivitymanager$localactivityrecord@40e587e8 not valid; activity running? 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.startactivitynow(activitythread.java:2023) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.localactivitymanager.movetostate(localactivitymanager.java:135) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.localactivitymanager.startactivity(localactivitymanager.java:347) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabhost$intentcontentstrategy.getcontentview(tabhost.java:749) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabhost.setcurrenttab(tabhost.java:413) 04-05 13:44:07.573: e/androidruntime(9725): @ android.widget.tabhost.addtab(tabhost.java:240) 04-05 13:44:07.573: e/androidruntime(9725): @ com.example.univer_city.profile.oncreate(profile.java:73) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activity.performcreate(activity.java:5104) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 04-05 13:44:07.573: e/androidruntime(9725): ... 18 more 04-05 13:44:07.573: e/androidruntime(9725): caused by: android.view.windowmanager$badtokenexception: unable add window -- token android.app.localactivitymanager$localactivityrecord@40e587e8 not valid; activity running? 04-05 13:44:07.573: e/androidruntime(9725): @ android.view.viewrootimpl.setview(viewrootimpl.java:567) 04-05 13:44:07.573: e/androidruntime(9725): @ android.view.windowmanagerglobal.addview(windowmanagerglobal.java:246) 04-05 13:44:07.573: e/androidruntime(9725): @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:69) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.dialog.show(dialog.java:281) 04-05 13:44:07.573: e/androidruntime(9725): @ com.example.univer_city.profile_inner_tab$loadallproducts.onpreexecute(profile_inner_tab.java:85) 04-05 13:44:07.573: e/androidruntime(9725): @ android.os.asynctask.executeonexecutor(asynctask.java:586) 04-05 13:44:07.573: e/androidruntime(9725): @ android.os.asynctask.execute(asynctask.java:534) 04-05 13:44:07.573: e/androidruntime(9725): @ com.example.univer_city.profile_inner_tab.oncreate(profile_inner_tab.java:49) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activity.performcreate(activity.java:5104) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 04-05 13:44:07.573: e/androidruntime(9725): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 04-05 13:44:07.573: e/androidruntime(9725): ... 28 more
i dont know whats problem , me?
Comments
Post a Comment