public void dispatchKeyEvent ( int code , int action ) { int keyCode = 0 ; int keyAction = 0 ; if ( code == BUTTON_1 ) { keyCode = KeyEvent . KEYCODE_BUTTON_1 ; } else if ( code == BUTTON_2 ) { keyCode = KeyEvent . KEYCODE_BUTTON_2 ; } if ( action == ACTION_DOWN ) { keyAction = KeyEvent . ACTION_DOWN ; } else if ( action == ACTION_UP ) { keyAction = KeyEvent . ACTION_UP ; } KeyEvent keyEvent = new KeyEvent ( keyAction , keyCode ) ; setKeyEvent ( keyEvent ) ; }
Synthesize and forward a KeyEvent to the library .