We created an android library which is working with dialogs. After testing it on a Samsung Galaxy S1 Plus I9005 with Android 2.3.6 we experienced, that a long press on the devices menu button closes the active dialog immediately. I do not even know the purpose of long-pressing that button.
For someone who does not know the device, this picture should show you what i mean:
The problem does not occur on devices running on Android 4.x. I tested it on a Samsung Galaxy S3 running Android 4.1.2 and even a Galaxy S1 with a Android 4.0.3 Custom ROM - no problem.
To suppress closing the dialog, i tried to override the onKeyDown
, onKeyUp
, onPrepareOptionsMenu
and other methods which seemed to be relevant, but non of them brought success or any valuable information. The same happened when i tried to debug into those methods, because the dialog was gone before the debugger reached any method i can override.
The dialogs are created by using the following way:
@Override
public Dialog onCreateDialog(final int pId) {
Dialog dialog;
switch (pId) {
case LOADING_DIALOG:
dialog = DialogCreator.createLoadingDialog(MyActivity.this));
break;
default:
dialog = null;
}
super.onCreateDialog(pId);
return dialog;
}
The DialogCreator
is just creating an AlertDialog by using:
new AlertDialog.Builder(pContext).create();
To prevent the dialog from being canceled I added:
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.setCancelable(false);
Anybody an idea why this is closing the dialog?
edit
While being on the 'Desktop' the long press on the menu button starts a Google search.