Sunday, 24 March 2019

Sticky overlay without WindowManager.LayoutParams.TYPE_PHONE

By sticky I mean a window that doesn't get closed by calling the launcher intent (intent.addCategory(Intent.CATEGORY_HOME).

Previously this was done with WindowManager.LayoutParams.TYPE_PHONE, but this type is now deprecated and throws an exception on api 28:

WindowManager$BadTokenException ... permission denied for window type 2002

The behavious is still possible since Facebook's Messenger does it, based on the assumption that facebook doesn't get system app permissions since it's pre-installed on a lot of roms.

Using WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY doesn't work.

Edit: The question is how to have an overlay window that doesn't get removed when user clicks the home button / calling the launcher intent. It's not the case for TYPE_APPLICATION_OVERLAY, it was the case for TYPE_PHONE but that's deprecated.



from Sticky overlay without WindowManager.LayoutParams.TYPE_PHONE

No comments:

Post a Comment