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 button press.
and put two option button in that dialog box cancel and ok.
Thank you...
Try out as below :
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
Use can use setCancellable(false); setCanceledOnTouchOutside(false); for the dialog itself, that should stop that dialog from closing by BACK and by tapping outside the dialog.
You can't override the HOME button.
Try this::
You need to create layout that you want to show in popup. you can create layout XML and use it like this:
You can also provide click events of button like this:
and show this popup like this: here you want to show this on button click then button view will be there.
There are many kind of
Dialogs
in Android. Please take a look at Dialogs. I guess what you are looking for is something likeAlertDialog
. This is the example of how you can implement onBackPress
button.