5

I just want to catch the backspace key. All other keys are working fine. The Log.i Message is also not triggered.

dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
    @Override
    public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
        Log.i(TAG, "keycode  " + keyCode);
        if (event.getAction() == KeyEvent.ACTION_UP)
             switch (keyCode) {  
             case KeyEvent.KEYCODE_ENTER:
                    sendChar(mBTCS, "unknown");
                    return true;   
             case KeyEvent.KEYCODE_MINUS:
                    sendChar(mBTCS, "Z");
                    return true;
             }
             return false;
    }
});

Can someone explain this?

Kiwi
  • 83
  • 1
  • 6
  • You haven't given enough information regarding whether you are using TYPE_NULL to get your events. If not, then you cannot expect key events to be generated reliably (although they may be generated in some cases, for some versions of Android). If you *are* using TYPE_NULL, then see this answer: http://stackoverflow.com/questions/18581636/android-cannot-capture-backspace-delete-press-in-soft-keyboard/19980975#19980975 – Carl Jan 31 '14 at 06:49

0 Answers0