How to send KeyEvents trough an input method service to a Dialog, or a Spinner menu?

Posted by shutdown11 on Stack Overflow See other posts from Stack Overflow or by shutdown11
Published on 2010-04-11T11:29:47Z Indexed on 2010/04/11 11:33 UTC
Read the original article Hit count: 189

Filed under:

I'm trying to implement an input method service that receives intents sent by a remote client, and in response to those sends an appropriate KeyEvent.

I'm using in the input method service this method

private void keyDownUp(int keyEventCode) {
        getCurrentInputConnection().sendKeyEvent(
                new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode));
        getCurrentInputConnection().sendKeyEvent(
                new KeyEvent(KeyEvent.ACTION_UP, keyEventCode));
    }

to send KeyEvents as in the Simple Sofykeyboard Sample, and it works in the home, in Activities... but it doesn't works when a Dialog or the menu of a Spinner is in foreground.

The events is sent to the parent activity behind the Dialog.

Is there any way to send keys and control the device like using the hardware keys from an input method?

© Stack Overflow or respective owner

Related posts about android