Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For the same, you can implement <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">AsyncTask</a> concept, and which is very much preferable in Android to implement threading task, by implementing this task, system itself handles the threading task like start, run, stop....etc. and that's why its known as as <a href="http://developer.android.com/resources/articles/painless-threading.html" rel="nofollow">Painless Threading</a>.</p> <p>If you have gone through <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow">AsyncTask</a> link then i am sure you have noticed those 4 methods of AsyncTask.</p> <p>For your problem, you can implement the AsyncTask as below:</p> <ol> <li>onPreExecute() - Display progress dialog</li> <li>doInBackground() - implement all the long running task</li> <li>onPostExecute() - dismiss progress dialog by calling <code>dialog.dismiss();</code></li> </ol> <p>I am sure you got it now. </p> <p>All the best.</p> <h2>Update:</h2> <p>you just need to write Dialog.Show() method inside the onPreExecute() method, and dialog.dismiss() inside the onPostExecute() method. And yes i have told 1000 times that you can't write Toast directly inside the doInBackground() method because Android doesn't allows to ride on the main thread, and if you still want to execute it then write the same Toast message inside the runOnUiThead method (this method should be inside the doInBackground().</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload