Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Location
    Queensland, Australia
    Posts
    12
    Rep Power
    0

    Default 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.

    AsyncTask and ProgressDialog-hiddeprogressdialog.png

    The for the AsyncTask is as follows

    Java 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

  2. #2
    Join Date
    Feb 2012
    Location
    Queensland, Australia
    Posts
    12
    Rep Power
    0

    Default Re: AsyncTask and ProgressDialog

    Has nobody come across this scenario before.

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •