Android App Exit Alert Show | Android tutorial

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

        final AlertDialog.Builder builder = 
        new AlertDialog.Builder(MainActivity.this);
        builder.setMessage("Are you sure to do exit?");
        builder.setCancelable(true);
        builder.setNegativeButton("Close", 
           new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.setPositiveButton("Exit", 
            new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
             finish();
         }
     });
        AlertDialog alertDialog = builder.create();
        alertDialog.show();

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Do You Want To Contact With me?

drop us a line and keep in touch