Home » Android » java – System overlay android 4.0

java – System overlay android 4.0

Posted by: admin June 16, 2020 Leave a comment


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 the touches.

basically the idea follows this app,
You can keep your app open, or always on top. it will run over any app.

Ive looked every where for information and even source code for the use on android 4.0 but no luck… Now.. I know for certain there are apps that still do this even on 4.0… there is still a way. Any ideas?

How to&Answers:

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 << 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.