showInputMethodPicker from notification not working in Android 9

耗尽温柔 提交于 2021-02-09 12:29:22

问题


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:


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.



来源:https://stackoverflow.com/questions/52036241/showinputmethodpicker-from-notification-not-working-in-android-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!