There is an app on the Google “Play Store” called “Screen Filter”, which is designed to cover the entire screen with some translucent black, to allow the screen to be dimmer than the minimum brightness.
It does this using a permission called “Display System-Level Alerts”.
-
Where is the documentation that allows me to do this in my app?
-
Can this “system-level alert” intercept touch events? This is so I can get my app to take over an Android that is supposed to stay in our building.
I like this approach because it prevents the phone from being turned off before it is turned over (which would trigger an alarm), unless of course there is a hammer involved.
Docs for
Manifest.Permissionshow that theSYSTEM_ALERT_WINDOWis the permission you are looking for. You would declare this permission in theManifestand then in aDialogor any other kind ofWindowyou would set this flagWindowManager.LayoutParams.TYPE_SYSTEM_ALERT. So for aDialogit would look like this:dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);Yes, it will be able to intercept touch events. System alerts, like a low battery warning, always open on top of all other applications, so whatever
Windowyou pop up will take focus, etc. Based on what you want to do with this, I’d imagine you could do something like: pop up aDialog(as a system level alert) which needs a password to make it go away.