0

I am implementing a custom keyboard with InputMethodService. Calling showInputMethodPicker from a service that is a chat head (a floating widget like in facebook messenger) when the selected keyboard is my custom one works but if current selected keyboard is something else e.g. Gboard, the input method picker UI doesn't show up, no error message on Run console in android studio. By selected keyboard, i mean the default keyboard in settings.

// inside main activity, start 'chat head' service when a button in app is clicked 
startService(Intent(this@MainActivity, FloatingViewService::class.java))

// inside 'chat head' service, show picker UI when a button in expanded 'chat head' menu is clicked
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.showInputMethodPicker()

How to make showInputMethodPicker work even though my custom keyboard is not selected or is it not possible? Not familiar with Android, so alternative approach is welcome (if the method above is wrong from the start)

Followed this blog post for creating the 'chat head' and this stackoverflow post for how to use showInputMethodPicker

nicolauscg
  • 115
  • 1
  • 5

1 Answers1

0

related post, question mentions about using a postDelay, so my current workaround is: when button clicked in chat head service, create an intent to start activity with a boolean data using putExtra, activity onCreate gets called, if the boolean is true, call showInputMethodPicker after some delay (500ms for me works), set boolean to false

start activity from service details

delay using postDelayed details

nicolauscg
  • 115
  • 1
  • 5