
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
None | size: 0.95 KB | hits: 28 | expires: Never
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Handle the back button
if (keyCode == KeyEvent.KEYCODE_BACK && isTaskRoot()) {
// Ask the user if they want to quit
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.quit)
.setMessage(R.string.really_quit)
.setPositiveButton(R.string.yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// Stop the activity
finish();
}
}).setNegativeButton(R.string.no, null).show();
return true;
} else {
return super.onKeyDown(keyCode, event);
}
}
procedure TSomeForm.CloseQuery(Sender: TObject; var ACtion: TCloseAction);
begin
if MessageDlg(mtConfirmation, 'Really quit?', [mbYes, mbNo], 0) = mrNo then
Action := caNone;
end;