I am showing the user the Input Method Picker like so and the picker pops up:
InputMethodManager im = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
im.showInputMethodPicker();
Now if the user dismisses the picker (for example by clicking outside the picker) I want to know that, that happened and do some action (like show a notification for example).
I know that in an Activity I can do the dirty way of checking the focus of the root layout and I know that with the Accessibility permission I can check if that system dialog is focused or not.
The problem is that I am running a service and I need to detect if the IME picker is showing or not even if I am not in my app (a third party app for example or even the Android keyboard settings) and also I find the Accessibility permission a bit confusing for the user therefore I would prefer to not resort to that and find an alternative way.
Is there an alternative way?