Guest User

Untitled

a guest
Jun 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. @Override
  2. public void onBackPressed() {
  3. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  4. builder.setMessage("Are you sure you want to exit?")
  5. .setCancelable(false)
  6. .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
  7. public void onClick(DialogInterface dialog, int id) {
  8. MyActivity.this.finish();
  9. }
  10. })
  11. .setNegativeButton("No", new DialogInterface.OnClickListener() {
  12. public void onClick(DialogInterface dialog, int id) {
  13. dialog.cancel();
  14. }
  15. });
  16. AlertDialog alert = builder.create();
  17. alert.show();
  18.  
  19. }
  20.  
  21. @Override
  22. public void onBackPressed() {
  23. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  24. builder.setMessage("Are you sure you want to exit?")
  25. .setCancelable(false)
  26. .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
  27. public void onClick(DialogInterface dialog, int id) {
  28. //finish();
  29. MyActivity.this.onSuperBackPressed();
  30. //super.onBackPressed();
  31. }
  32. })
  33. .setNegativeButton("No", new DialogInterface.OnClickListener() {
  34. public void onClick(DialogInterface dialog, int id) {
  35. dialog.cancel();
  36. }
  37. });
  38. AlertDialog alert = builder.create();
  39. alert.show();
  40. /*
  41. if (handleCancel()){
  42. super.onBackPressed();
  43. }
  44. */
  45. }
  46.  
  47. public void onSuperBackPressed(){
  48. super.onBackPressed();
  49. }
  50.  
  51. utility.makeAlertDialog("Cancel Verification","Do you want to cancel the verification process","Cancel Verification",new DialogInterface.OnClickListener(){
  52. @Override
  53. public void onClick(DialogInterface dialog, int which) {
  54. utility.failureToast("OTP verification");
  55. Intent intent = new Intent(MobileOTPActivity.this,MobileNumberLoginActivity.class);
  56. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  57. startActivity(intent);
  58. finish();
  59. MobileOTPActivity.this.onBackPressed();
  60. }
  61. },"Close");
Add Comment
Please, Sign In to add comment