Answers for "show alert dialog on exit android"

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
0

alert dialog not displayed android

If : alert.show(); doesn't works try this :

anyViewObject.post(() -> {
  // Create your alert here
  alert.show();
});
Posted by: Guest on October-15-2021

Code answers related to "show alert dialog on exit android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language