Skip to content

Instantly share code, notes, and snippets.

@OrniNoor
Created February 8, 2017 19:42
Show Gist options
  • Save OrniNoor/53d51ac328171b972aba9785108c0645 to your computer and use it in GitHub Desktop.
Save OrniNoor/53d51ac328171b972aba9785108c0645 to your computer and use it in GitHub Desktop.
Exit dialouge android
protected void exitByBackKey() {
AlertDialog alertbox = new AlertDialog.Builder(this)
.setMessage("Do you want to exit application?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
finish();
//close();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface arg0, int arg1) {
}
})
.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment