Answers for "exit dialog android studio"

1

exit dialog android studio

Best Code 

@Override
public void onBackPressed() {
    new AlertDialog.Builder(this)
           .setMessage("Are you sure you want to exit?")
           .setCancelable(false)
           .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                   ExampleActivity.super.onBackPressed();
               }
           })
           .setNegativeButton("No", null)
           .show();
}
Posted by: Guest on September-30-2021
1

close dialog android

if (dialog.isShowing) {
     dialog.dismiss()
}
Posted by: Guest on August-25-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language