System overlay android 4.0

后端 未结 1 1585
清歌不尽
清歌不尽 2021-01-05 03:02

Before android 4.0 you could create and overlay over any app with TYPE_SYSTEM_OVERLAY and get touches with FLAG_WATCH_OUTSIDE_TOUCH... Now with android 4 you cant receive th

相关标签:
1条回答
  • 2021-01-05 03:21

    I found a full sample app here that works for Android 4.0

    Here is the highlight:

    To create an overlay view, when setting up the LayoutParams DON'T set the type to TYPE_SYSTEM_OVERLAY.

    Instead set it to TYPE_PHONE.

    Use the following flags:

    FLAG_NOT_TOUCH_MODAL

    FLAG_WATCH_OUTSIDE_TOUCH

    FLAG_NOT_TOUCH_MODAL << This one is quite important. Without it, focus is given to the overlay and soft-key (home, menu, etc.) presses are not passed to the activity below.

    Also make sure you add the SYSTEM_ALERT_WINDOW permission to the mainifest file.

    0 讨论(0)
提交回复
热议问题