How to get a window from InputMethodService?

Is it possible to get a Window object for a specific view (or PopupWindow)?

My application is a keyboard, so this is a Service (InputMethodService), not an Activity. Therefore, I cannot use Activity.getWindow (). However, it has Views, so it probably has a window too, no? How to get it?

Thanks in advance...

+4
source share
1 answer

I found a solution:

InputMethodService ims; ... Dialog dialog = ims.getWindow(); Window window = dialog.getWindow(); 

or simply:

  Window window = ims.getWindow().getWindow(); 

(This works with InputMethodService and is not necessarily applicable to other services.)

+1
source

Source: https://habr.com/ru/post/1443738/


All Articles