I want to attach key event from soft keyboard without EditText. I already override some method. But not work.
Here is my code that open soft keyboard.
public class MyActivity extends Activity {
public void OpenKeyboard() {
InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.toggleSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if(e.getAction() == KeyEvent.ACTION_DOWN)
Log.d("displatch", "clicked.."); // NOT-WORKING..
return super.dispatchKeyEvent(e);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN)
Log.d("onKeyDown", "clicked.."); // NOT-WORKING..
return super.onKeyDown(keyCode, event);
}
}
Please find a solution. Thx.