ProgressDialog in AsyncTask: Dynamic Update Text/Title
Sometimes, you may want to update the text shown in the progress dialog. If you try to perform this in doInBackground() you’ll get an exception along the lines:
Only the original thread that created a view hierarchy can touch its views
The solution is to not do it in doInBackground() but instead trigger onProgressUpdate() and perform the update there. To do this, you’ll need to pass an object. Luckily, the type of object is defined by the second parameter of the declaration AsyncTask<Params, Progress, Result>.
Progress object can be a
String and you can pass a variable number of arguments to the
A little experiment: If you find this post and ad below useful, please check the ad out 🙂