Class KeyLibrary

Object
KeyLibrary

public class KeyLibrary
extends Object
The CASIO Enterprise Developer Tools Key Library

Since:
2.00
API Note:
The SAM Library is bound to the calling application on application startup time automatically.
The Library's lifecycle therefore depends on the application lifecycle.
Due to the Lifecycle of Android Applications and the underlying timing, it is strongly advised not to call any Library Methods inside the onCreate method.
When the activity is being launched (and hence the process gets created), the same applies to the onStart and onResume methods.
If you need to call any Library methods at application start in one of the above mentioned methods, you should use the Callback Mechanism offered by the onLibraryReady method instead.
For instance, instead of calling KeyLibrary.setDefaultKeyCode(KeyLibraryConstant.KEYID.CENTERTRIGGER) directly in onCreate, use this code to postpone it to a Callback appropriately:
KeyLibrary.onLibraryReady(new LibraryCallback() {
     public void onLibraryReady() {
         KeyLibrary.setDefaultKeyCode(KeyLibraryConstant.KEYID.CENTERTRIGGER);
     }
 });

Which can be simplified to:
KeyLibrary.onLibraryReady(() -> { KeyLibrary.setDefaultKeyCode(KeyLibraryConstant.KEYID.CENTERTRIGGER); });
  • Method Summary

    Modifier and Type Method Description
    static void broadcastKey​(String action, String extra, KeyEvent event)
    Sends an ordered broadcast key event to all registered receivers for the given intent.
    Use this method to circumvent permission issues on key broadcasts with latest android versions.
    static int changeKCMapFile​(String path, byte[] data)
    Change the current Key Character Map File to a new one, providing the bytes that make up the new Key Character Map file
    static boolean changeKCMapFileToDefault()
    Change the current Key Character Map File to the System Default one
    static void changeTrayIcon​(KeyEvent event)
    Update the Keyboard's Tray Icon to reflect a state as if the given KeyEvent would just have occured
    static int clearFnLaunchApplication​(int nID)
    Clear the application information to be launched when the specified key is pushed in Fn mode.
    If you clear the launched application, the key code for the given KEYID is generated again.
    static int clearLaunchApplication​(int nID)
    Clear the application information to be launched when the specified key is pushed in 1/A/a mode.
    If you clear the launched application, the key code for the given KEYID is generated again.
    static String getCurrentKCMapFile()
    Get the current Key Character Map File name
    static boolean getFixedNumberMode()
    Check whether key input is limited to numeric input only
    static int getFnLaunchApplication​(int nID, ApplicationInfo appInfo)
    Get the application to be launched when the specified key is pushed in Fn mode.
    static int getFnUserKeyCode​(int nID)
    Get the key code generated when the specified key is pushed in Fn mode.
    static int getKeypadMode()
    Get the currently active Input Mode for the Hardware Keyboard
    static int getLaunchApplication​(int nID, ApplicationInfo appInfo)
    Get the application to be launched when the specified key is pushed in 1/A/a mode.
    static int getTestMode()
    Check whether the Hardware Keyboard is running in "Test Mode"
    static int getUserKeyCode​(int nID)
    Get the key code generated when the specified key is pushed in 1/A/a mode.
    static boolean hasHardwareKey​(int keyCode)
    Check whether a certain keycode corresponds to a key on the Hardware Keyboard
    static boolean hasWakeupRes​(KeyEvent event)
    Check whether a certain KeyEvent can act as Wakeup Resource
    static boolean hijackingKey​(KeyEvent event, boolean useCache)
    Convert a KeyEvent according to alternative mapping tables and apply it after conversion
    static boolean isDirectInputStyle()
    Check whether "Direct Input Mode" is active or not.
    static boolean isFinishedHandle()
    Check whether all cached Key Events have been processed
    static boolean isKeyControlMode()
    Check whether key input is routed through the hardware keyboard driver
    static boolean isMethodSupported​(String methodName)
    Check whether the Method indicated by the String methodName parameter is supported on the currently active device
    static boolean isMethodSupported​(BigInteger method)
    Check whether the Method indicated by the BigInteger method parameter is supported on the currently active device
    static boolean isWakeupRes​(int keyCode)
    Check whether a certain keycode is set to act as Wakeup Resource
    static void onLibraryReady​(LibraryCallback callback)
    Add a new Callback to the Queue of Callbacks to be processed once the KeyLibrary Service becomes available
    static void performKeyPressFeedback​(KeyEvent event)
    Apply the configured Feedback (Sound, Vibration, Wakeup, Tray Icon) for the corresponding KeyEvent
    static boolean removeKCMapFile()
    Removes the current Key Character Map File and changes back to the System Default one
    static int setDefaultKeyCode​(int nID)
    Reset the key code generated when the specified key is pushed in 1/A/a mode to default Key Code setting.
    static boolean setDirectInputStyle​(boolean enable)
    Set whether the "Direct Input Mode" shall be used
    static boolean setFixedNumberMode​(boolean on)
    Set whether the Input Mode shall be fixed to numeric input
    static int setFnDefaultKeyCode​(int nID)
    Reset the key code generated when the specified key is pushed in Fn mode to default Key Code setting.
    static int setFnLaunchApplication​(int nID, ApplicationInfo appInfo)
    Set the application to be launched when the specified key is pushed in Fn mode.
    If you set the launched application with this function, the key code is not generated when the key is pushed.
    static int setFnUserKeyCode​(int nID, int KeyCode)
    Set the key code generated when the specified key is pushed in Fn mode.
    static boolean setKeyControlMode​(boolean enable)
    Set whether key input shall be routed through the hardware keyboard driver
    static boolean setKeypadMode​(int mode)
    Activate a certain Input Mode for the Hardware Keyboard
    static int setLaunchApplication​(int nID, ApplicationInfo appInfo)
    Set the application to be launched when the specified key is pushed in 1/A/a mode.
    If you set the launched application with this function, the key code is not generated when the key is pushed.
    static int setUserKeyCode​(int nID, int KeyCode)
    Set the key code generated when the specified key is pushed in 1/A/a mode.
    static boolean setWakeupRes​(int resourceID, boolean enabled)
    Activate or deactivate a certain keyboard resource to act as Wakeup Resource
    static void updateMetaState​(KeyEvent event)
    Update the Tray Icon Meta State for the corresponding KeyEvent