Advertisement
Guest User

Untitled

a guest
May 20th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1.     //Reference: https://stackoverflow.com/questions/6413700/android-proper-way-to-use-onbackpressed-with-toast
  2.     //Accessed on 12 May 2018
  3.     @Override
  4.     public void onBackPressed() {
  5.         new AlertDialog.Builder(this)
  6.                 .setMessage(R.string.are_you_sure_exit)
  7.                 .setNegativeButton(R.string.no, null)
  8.                 .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
  9.  
  10.                     public void onClick(DialogInterface arg0, int arg1) {
  11.                         DefaultSettings.super.onBackPressed();
  12.                     }
  13.                 }).create().show();
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement