I previously extended the class Dialogfor my dialogs, and I had to use the following code segment in my dialogs so that they would not be fired when I press the search key on the phone:
setOnKeyListener(new OnKeyListener()
{
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_SEARCH)
return true;
else
return false;
}
});
Now I use the class DialogFragmentfor my dialogs. Unfortunately, it DialogFragmenthas the same problem as Dialogin this dialog they are rejected by pressing the phone search key (regardless of the status of canceling the dialog). The two-sided problem is that it DialogFragmentdoes not have a method setOnKeyListener, so the above code segment is no longer applied.
Does anyone know how I can get my dialogs (when shown) to ignore search key presses?
. onKeyUp, , , onKeyUp DialogFragment. , , DialogFragment .