1

I made an app ,and there is a progress dialog on one of its activities . I want to show an alert dialog , when progress dialog has finished. How can I do it?

please guid me...

thanks.

poursina
  • 87
  • 1
  • 1
  • 11
  • well, first add your code, second you can show your alert when you dismiss your progress dialog, or you can use setOnDismissListener(...) – Vilen May 03 '14 at 13:31

1 Answers1

3

I am assuming you already know how to show the progress dialog. The progress dialog has two listeners, onDismiss and onCancel. Check out the difference here : What is the difference between a dialog being dismissed or canceled in Android?

You can choose to put either of the listeners depending on your requirements. Here's a sample code.

progressDialog.setOnDismissListener(new OnDismissListener() {
    @Override
    public void onDismiss(DialogInterface dialog) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            context);

        // set title
        alertDialogBuilder.setTitle("Your Title");

        // set dialog message
        alertDialogBuilder
            .setMessage("Message")
            .setCancelable(false)
            .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                }
              })
            .setNegativeButton("No",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                }
            });

            // create alert dialog
            AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();
        }
    });
Community
  • 1
  • 1
Shivam Verma
  • 7,973
  • 3
  • 26
  • 34