[android-developers] Re: How do you show 'Are you sure you want to quit' dialog?
Hi,
here is the code to get the confirmation screen,
public void onBackPressed() {
Builder builder = new AlertDialog.Builder(context);
builder.setTitle("application");
builder.setIcon(R.drawable.icon1);
builder.setMessage(""Would you like to exit"");
builder.setNegativeButton(""Exit"",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
System.exit(RESULT_OK);
}
});
builder.setPositiveButton(""Not now"",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
builder.show();
//
}
paste this code in the intent where you want to have a exit confirmation,
All the best,
Thank
Shiva Shankar
On Wednesday, November 28, 2012 2:45:36 AM UTC+5:30, Subodh Nijsure wrote:
Hi,--I want to present a yes/no dialog when user enters back, on main activity 'are you sure you want to quit? ' And if they click ok, quit the application.To do this I show a dialog in onDestroy() that asks yes/no question but that doesn't work. What is correct way to implement 'are you sure you want to quit the application' dialog?-Subodh
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home