4

Can someone please help me to get WindowManager.LayoutParams combination that can pass events to layers under TYPE_SYSTEM_ALERT or similar overlay type (that sits top of every other window).

Problem: My problem is when the window type TYPE_SYSTEM_ALERT get the focus it stop passing the motion events to the other applications under it.

Sample code

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
        WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
        PixelFormat.TRANSLUCENT);

Requirement: I need to get the TYPE_SYSTEM_ALERT or similar overlay type that stay on top of every other window and also gets the motion events as well as passes the motion events to any overlay under the top layer (Possibly TYPE_SYSTEM_ALERT).

I need it to be stay on top of all other windows as I need to draw images on top of all windows without interrupting the motion event.

SAN
  • 959
  • 4
  • 11
  • 17

1 Answers1

0

Well, from the docs it says:

TYPE_SYSTEM_ALERT - Window type: system window, such as low power alert. These windows are always on top of application windows. In multiuser systems shows only on the owning user's window.

Link here: https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#TYPE_SYSTEM_ALERT

I tested this a bit and it means that the views show up on top of pretty much everything (including the permission dialogs since Android 6.0) - causing them to lose focus. Keyguard layer still stays on top. Yes, you might lose the focusable attribute on your views, but you could potentially handle everything in the touch listener. For example, take a look at this post: How to use View.OnTouchListener instead of onClick

Community
  • 1
  • 1
milosmns
  • 3,595
  • 4
  • 36
  • 48