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
There are many kind of Dialogs
in Android. Please take a look at Dialogs. I guess what you are looking for is something like AlertDialog
. This is the example of how you can implement on BackPress
button.
@Override
public void onBackPressed() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Do you want to logout?");
// alert.setMessage("Message");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//Your action here
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
}