Question: I am saving the imae from drawing canvas.
It takes some seconds to geting save to the sdcard.
So, During the process of save i want to show the dialog that the Image getting save...

So how to implement the progress dialog for that ?

The code for Image save is as like below:

```
 case R.id.saveBtn:
            Toast.makeText(getApplicationContext(), "Save", Toast.LENGTH_SHORT).show();
            final Activity currentActivity  = this;
            Handler saveHandler = new Handler(){
                @Override
                public void handleMessage(Message msg) {
                    final AlertDialog alertDialog = new AlertDialog.Builder(currentActivity).create();
                    alertDialog.setTitle("Drawing App");
                    alertDialog.setMessage("Your drawing had been saved :)");
                    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            return;
                        }
                    });
                    alertDialog.show();
                }
            } ;

           new ExportBitmapToFile(this,saveHandler, drawingSurface.getBitmap()).execute();

        break;

```

Answer: 
Since you are using `AsyncTask` (`ExportBitmapToFile`) you can call `ProgressDialog` in `preExecute()` and dismiss it in `postExecute` method. There are no `Handler`s required to do this.

**edit**

```
class ExportBitmapToFile extends AsyncTask<...> {
    private ProgressDialog  m_progressDialog = null;
    .... 

    @Override
    protected void onPreExecute(){
        m_progressDialog = new ProgressDialog(m_context);
        m_progressDialog.setMessage("please wait...");
        m_progressDialog.setCancelable(false);
        m_progressDialog.show();
    }

    @Override
    protected void onPostExecute(HashMap<String, String> result){
        m_progressDialog.dismiss();
        //your alert dialog with message to user
        AlertDialog.Builder builder = new AlertDialog.Builder(currentActivity);
            builder.setTitle("Drawing App");
            builder.setMessage("Your drawing had been saved :)");
            builder.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    return;
                }
            });
        alertDialog = builder.create()
        alertDialog.show();
    } 
}

```
You should use onPreExecute and onPostExecute in your ExportBitmapToFile AsyncTask Class so you should add something like that to that class.

```
    @Override
    protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        if (progressDialog.isShowing()) {
            progressDialog.dismiss();

        }
        super.onPostExecute(result);
    }

    @Override
    protected void onPreExecute() {

        progressDialog = ProgressDialog.show(context, "Message",
                "Loading");

        super.onPreExecute();

    }

```