How to display and remove an android progress dialog


I can get a progress bar to appear with the following code

pd =, "", "Loading. Please wait...", true);

straight forward, but once I have the code execute I want it to go away, but when I run the dismiss method after I never see the dialog box show at all.

Heres the code in context which is wrapped in oncreate

pd =, "", "Loading. Please wait...", true);
setListAdapter(new CustomAdapter(myActivity.this));

I thought you can show/dismiss progress dialog's anywhere in the activity but I must be wrong.

here is the code that I got to work

private class UpdateFeedTask extends AsyncTask<MyActivity, Void, Void> {

    private ProgressDialog mDialog;

    protected void onPreExecute() {
        Log.d(TAG, " pre execute async");
        mDialog =,"Please wait...", "Retrieving data ...", true);


    protected void onProgressUpdate(Void... progress) {
        Log.d(TAG, " progress async");

    protected Void doInBackground(MyActivity... params) {
        // TODO Auto-generated method stub
        return null;

    protected void onPostExecute(Void result) {
        Log.d(TAG, " post execute async");