multithreading - Android close activity after thread ends -


i have activity, , buttonclick call thread post json php file. want activity closed after thread ends. how can that?

this click event:

button bsave = (button) findviewbyid(r.id.button3);     view.onclicklistener eventhandlerx = new view.onclicklistener() {         @override             public void onclick(view arg0) {                        sendjson( urlx, jsonarray);                     }     ... 

and thread:

private void sendjson(final string urlx, final jsonarray jsonarray) {     thread t = new thread() {         public void run() {         looper.prepare();         ...}     ...} }  

where can call finish() in order close activity? thank you

you can call finish() anywhere within ui thread. can execute code within ui thread using aysnctask's onpostexecute (replace thread it) or starting runnable using activity's runonuithread.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -