Possible Duplicate:
Finish the calling activity when AsyncTask completes
I know that I have to use asyncTask for operations that take long like db writing.
However, one of my issues is how to tell My activity not close until operation is done.
Example:
I have Activity A that should do a DB insert when the user hit submit. So when user hit submit, I am creating an asyncTask to update the db. The problem is I have it like
new MyAsyncTask().execute()
finish();
As a result, my activity is closing before the asyncTask is completed. How can I ensure that my activity stays open until MyAsyncTask is done processing
Thank you
You can write
finish()inonPostExecute() of async task.