전 아래처럼 구현했었어요.
private void createEndingPopup()
{
String strEndingInfo = "";
strEndingInfo = "정말 종료하시겠습니까?";
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(strEndingInfo)
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
bEnding = false;
}
});
AlertDialog alert = builder.create();
alert.show();
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
//Toast.makeText(ARAptLand.this, "ending", Toast.LENGTH_SHORT).show();
createEndingPopup();
if (!bEnding) {
return false;
} else {
finish();
}
}
return super.onKeyDown(keyCode, event);
}