android - how to show alert after calling the webservice -


this question has answer here:

in activity calling webservices. after webservice returns result, have show alert. since alert ui part, think inside onpostexecute() have write alert code. when error coming.

error shown:

12-02 09:59:08.508: error/androidruntime(451): uncaught handler: thread main exiting  due uncaught exception 12-02 09:59:08.528: error/androidruntime(451):  android.view.windowmanager$badtokenexception: unable add window -- token  android.app.localactivitymanager$localactivityrecord@4378eb50 not valid;  activity running? 12-02 09:59:08.528: error/androidruntime(451):     @  android.view.viewroot.setview(viewroot.java:456) 12-02 09:59:08.528: error/androidruntime(451):     @  android.view.windowmanagerimpl.addview(windowmanagerimpl.java:177) 12-02 09:59:08.528: error/androidruntime(451):     @  android.view.windowmanagerimpl.addview(windowmanagerimpl.java:91) 12-02 09:59:08.528: error/androidruntime(451):     @  android.view.window$localwindowmanager.addview(window.java:409) 12-02 09:59:08.528: error/androidruntime(451):     @ android.app.dialog.show(dialog.java:238) 12-02 09:59:08.528: error/androidruntime(451):     @  android.app.alertdialog$builder.show(alertdialog.java:802) 12-02 09:59:08.528: error/androidruntime(451):     @    com.myapp.android.activities.register$postcodetask.onpostexecute(register.java:291) 12-02 09:59:08.528: error/androidruntime(451):     @     com.myapp.android.activities.register$postcodetask.onpostexecute(register.java:1) 12-02 09:59:08.528: error/androidruntime(451):     @ android.os.asynctask.finish(asynctask.java:416)  12-02 09:59:08.528: error/androidruntime(451):     @  android.os.asynctask.access$300(asynctask.java:127) 12-02 09:59:08.528: error/androidruntime(451):     @  android.os.asynctask$internalhandler.handlemessage(asynctask.java:428) 12-02 09:59:08.528: error/androidruntime(451):     @  android.os.handler.dispatchmessage(handler.java:99) 12-02 09:59:08.528: error/androidruntime(451):     @  android.os.looper.loop(looper.java:123) android.app.activitythread.main(activitythread.java:4203) 12-02 09:59:08.528: error/androidruntime(451):     @  java.lang.reflect.method.invokenative(native method) 12-02 09:59:08.528: error/androidruntime(451):     @  java.lang.reflect.method.invoke(method.java:521) 12-02 09:59:08.528: error/androidruntime(451):     @  com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:791) 12-02 09:59:08.528: error/androidruntime(451):     @  com.android.internal.os.zygoteinit.main(zygoteinit.java:549) 12-02 09:59:08.528: error/androidruntime(451):     @ dalvik.system.nativestart.main(native  method) 

can please solve issue. in advance :)

you need execute alert code in ui thread. there few ways of doing example

runonuithread(new runnable() {     public void run() {         toast.maketext(myactivity.this, "hello there", toast.length_long).show();     } }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -