Wednesday, 7 August 2013

Android close activity after thread ends

Android close activity after thread ends

I have an activity, and a buttonClick where I call a Thread that will POST
some JSON to a PHP file. I want the activity to get Closed after the
thread ends. How can I do that?
This is my 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 this is my Thread:
private void sendJson(final String urlx, final JSONArray jsonarray) {
Thread t = new Thread() {
public void run() {
Looper.prepare();
...}
...}
}
Where can I call finish() in order to close my activity? Thank you

No comments:

Post a Comment