Skip to content

Instantly share code, notes, and snippets.

@ted80
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ted80/60b77ed535f65911ef68 to your computer and use it in GitHub Desktop.
Save ted80/60b77ed535f65911ef68 to your computer and use it in GitHub Desktop.
back button
@Override
public void onBackPressed()
{
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Exit")
.setMessage("Are you sure you want to quit?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
finish();
}
})
.setNegativeButton("No", null)
.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment