问题
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