Reputation: 14386
I've got a problem with a button click. When user clicks on my button, the screen is blocked for some seconds, because of the operations that activity has to execute. If I want to open a toast notification that displays a loading message, how I can execute theese operations in background? And if result is ok, how I can kill previous activity and open an other one?
Upvotes: 0
Views: 216
Reputation: 80340
You should use AsyncTask. It was created for just this purpose:
Show ProgressDialog in AsyncTack.onPreExecute() method. Toast is not fit for this task as you can not control how long it is shown.
Do work in AsyncTack.doInBackground() method.
When done, AsyncTack.onPostExecute() will be called: cancel dialog, start new activity.
Upvotes: 4