i have an android application .. i want whrn the user clicks on exit button it will displays a confirmation message and if he clicked yes the close the whole application ..
tried this code but didn't work:
AlertDialog.Builder alertBuilder=new AlertDialog.Builder(AdminEditProfile.this);
alertBuilder.setTitle("Exit");
alertBuilder.setMessage("Are you sure you want to exit from the application?");
alertBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
});
alertBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alertBuilder.create().show();
is there a way to do it >
please help, thank you :).