Wednesday, 4 November 2015

Dialog box confirmation before exit android app.

Leave a Comment
This is the code to trigger dialog box before you exit the application in android.


  private void ShowMessageExit(String Message){  
     new AlertDialog.Builder(this)  
         .setMessage(Message)  
         .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {  
           public void onClick(DialogInterface dialog, int which) {  
             android.os.Process.killProcess(android.os.Process.myPid());  
             System.exit(0);  
           }  
         })  
         .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {  
           public void onClick(DialogInterface dialog, int which) {  
             // do nothing  
           }  
         })  
         .setIcon(android.R.drawable.ic_dialog_alert)  
         .show();  
   }  



By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.