Guest User

Untitled

a guest
Jul 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public void onBackPressed(){
  2. backpress = (backpress + 1);
  3. Toast.makeText(getApplicationContext(), " Press Back again to Exit ", Toast.LENGTH_SHORT).show();
  4.  
  5.  
  6. if (backpress>1) {
  7. this.finish();
  8. }
  9.  
  10. }
  11.  
  12. @Override
  13. public void onBackPressed() {
  14. new AlertDialog.Builder(this)
  15. .setTitle("Really Exit?")
  16. .setMessage("Are you sure you want to exit?")
  17. .setNegativeButton(android.R.string.no, null)
  18. .setPositiveButton(android.R.string.yes, new OnClickListener() {
  19.  
  20. public void onClick(DialogInterface arg0, int arg1) {
  21. WelcomeActivity.super.onBackPressed();
  22. }
  23. }).create().show();
  24. }
Add Comment
Please, Sign In to add comment