I’m start InputMethodService from activity and want service send keyEvent to phone
i’m test sendKeyEvent in onBindInput and test by open soft keyboard by search in google chrome. it’s work. but i try to sendKeyEvent in onStart but my app was crash.
public class EDMTKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener {
private KeyboardView kv; private Keyboard keyboard; private boolean isCaps = false; private Intent intent; @Override public void onStart(Intent intent, int startid) { String Receive = intent.getStringExtra("Command"); Toast.makeText(this, "Service Started "+Receive, Toast.LENGTH_LONG).show(); InputConnection ic = getCurrentInputConnection(); ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)); ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK)); }
}