showInputMethodPicker from notification not working in Android 9

911 Views Asked by At

My app sometimes shows a notification to simplify switching to the app's internal input method. Therefore, I am executing

((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).showInputMethodPicker();

when the user clicks the notification.

This has worked so far, but does not always work on Android 9: When my app is in foreground, it works. When it is not, nothing happens. On logcat, I see a warning

"Warning 889 InputMethodManagerService Ignoring showInputMethodPickerFromClient of uid 10210: com.android.internal.view.IInputMethodClient$Stub$Proxy@edf46f0".

Is there any way to make this work again?

Update: I have tried to create an activity, calling showInputMethodPicker(); in onResume(). This works (if I use postDelayed() with a relatively long delay which is unfortunate), but I cannot get the activity to close itself automatically. So this doesn't seem to be a good way.

1

There are 1 best solutions below

0
Flnch On

The problem can be solved by setting the WRITE_SECURE_SETTINGS permission for your App.

Unfortunately, this requires issuing one adb command:

adb shell pm grant com.name.app android.permission.WRITE_SECURE_SETTINGS

where com.name.app is the package name of your app.