Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System overlay android 4.0

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, http://www.appbrain.com/app/smart-taskbar-%28sidebar%29/com.smart.taskbar 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?

like image 370
NightSkyCode Avatar asked Feb 04 '13 20:02

NightSkyCode


1 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

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.

like image 56
StarPinkER Avatar answered Nov 11 '22 09:11

StarPinkER