If you use setdefakeykeymode () in the oncreate () method of activity, you can enable the dialer in the current activity, execute the shortcut key, start local search, and start global search.
What are the parameters in setdefakeykeymode for starting? For different parameters, see:
/**
* Use with {@ link # setdefakeykeymode} to turn off default handling
* Keys.
*
* @ See # setdefakeykeymode
*/
Static public final int default_keys_disable = 0; // if this is set, the buttons in the activity do not respond.
/**
* Use with {@ link # setdefakeykeymode} to launch the dialer during default
* Key handling.
*
* @ See # setdefakeykeymode
*/
Static public final int default_keys_dialer = 1; // if this is set, the dial is opened by pressing the key in the activity.
/**
* Use with {@ link # setdefakeykeymode} to execute a menu shortcut cut in
* Default key handling.
*
* <P> that is, the user does not need to hold down the menu key to execute menu shortcuts.
*
* @ See # setdefakeykeymode
*/
Static public final int default_keys_shortcut = 2; // if this is set, the shortcut key is enabled when the key is clicked in the activity.
/**
* Use with {@ link # setdefakeykeymode} to specify that unhandled keystrokes
* Will start an application-defined search. (If the application or activity does not
* Actually define a search, the keys will be ignored .)
*
* <P> see {@ link Android. App. searchmanager Android. App. searchmanager} for more details.
*
* @ See # setdefakeykeymode
*/
Static public final int default_keys_search_local = 3; // if this is set, the local search will be enabled by pressing the key in the activity.
/**
* Use with {@ link # setdefakeykeymode} to specify that unhandled keystrokes
* Will start a global search (typically web search, but some platforms may define Alternate
* Methods for global search)
*
* <P> see {@ link Android. App. searchmanager Android. App. searchmanager} for more details.
*
* @ See # setdefakeykeymode
*/
Static public final int default_keys_search_global = 4; // if this is set, the global search is enabled by pressing the key in the activity.
Select the default key handling for this activity. this controls what will happen to key events that are not otherwise handled, the number key will automatically search for the corresponding button ). the default mode (DEFAULT_KEYS_DISABLE
) Will simply drop them on the floor. Other modes allow you to launch the dialer (DEFAULT_KEYS_DIALER
), Execute a shortcut cut in your options menu without requiring the menu key be held down (DEFAULT_KEYS_SHORTCUT
), Or launch a search (DEFAULT_KEYS_SEARCH_LOCAL
AndDEFAULT_KEYS_SEARCH_GLOBAL
).
Note that the mode selected here does not impact the default handling of system Keys (because they all work with buttons without handled, such as number keys .), Such as the "back" and "menu" keys, and your activity and its views always get a first chance to receive and handle all application keys.
Parameters
Mode |
The desired default key mode constant. |
See also
DEFAULT_KEYS_DISABLE
DEFAULT_KEYS_DIALER
DEFAULT_KEYS_SHORTCUT
DEFAULT_KEYS_SEARCH_LOCAL
DEFAULT_KEYS_SEARCH_GLOBAL
onKeyDown(int, KeyEvent)
To sum up, the default value of setdefakeykeymode is default_keys_disable. Therefore, no response is returned when you click a number key. However, after default_key_search_local is set, clicking the number key again will start the local search function, I think it is about setting the default button mode. By default, no response is made. Subsequent operations will be performed.