Search code examples
androidoperating-systemandroid-softkeyboardkeyeventshift

How to set SHIFT state of Google SIP from an Android Application


I am working on a specific requirement where I need to set the SHIFT state of the Google SIP from the Android Application. My question is, is there any API available for Google SIP (GBoard) which can set the SHIFT mode (ON or OFF) for the keyboard?

I have tried Instrumentation and View.dispatchKeyEvent() as below but it's not generating the shift state ON/Off in Google SIP

view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
Thread.sleep(100);
view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));

Additional information: We have a custom ROM for our device. I have already looked for such public API which can set the SHIFT mode for "LatinIME" SIP but I did not find any such API.

Thanks in Advance


Solution

  • After doing thorough analysis what I confirmed is there is no way to set the SHIFT state of GBOARD unless google provides the API in future android release.

    I was able to achieve this in LatinIME keyboard, Android's default keyboard, through changes in the keyboard (LatinIME) application itself.

    Thanks