1 Attachment(s)
AsyncTask and ProgressDialog
Hi All,
I am using an asynctask class to compute data in the background while showing a progressdialog.
On completion of the background task the data is displayed on the screen
Everything works as expected except the progressdialog is running in the background behind the dialog as show in the diagram below.
Has anyone had this happen to them and how did you fix it.
Attachment 3428
The for the AsyncTask is as follows
Code:
private class MyProgressBarDialog extends AsyncTask<Void, Void, Void>
{
protected void onPreExecute()
{
super.onPreExecute();
mProgressDialog = new ProgressDialog(getContext());
mProgressDialog.setIndeterminate(true);
mProgressDialog.setMessage("Please wait while loading");
mProgressDialog.setCancelable(false);
mProgressDialog.show();
}
protected Void doInBackground(Void... params)
{
try
{
buildGrid();
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void unused)
{
super.onPostExecute(unused);
if (mProgressDialog.isShowing())
{
mProgressDialog.dismiss();
}
renderGrid();
}
}
Thanks in Advance
Re: AsyncTask and ProgressDialog
Has nobody come across this scenario before.
Regards