i want create modal dialog box for my application.
so when modal dialog box open the other activities are blocked. no event are done like back button press or home butto
Try out as below :
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to exit?") .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MyActivity.this.finish(); } }) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create();
For the Home Key event :
No, it is not possible to get the Home key event in android. From the documentation of the Home keycode: http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME
public static final int KEYCODE_HOME
Key code constant: Home key. This key is handled by the framework and is never delivered to applications.