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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -