Android: System tools: displaying system level alerts: how to use this permission?

Google’s “Play Store” has a “Screen Filter” application that is designed to cover the entire screen with a few translucent inks so that the screen is dimmer than the minimum brightness.

He does this using the Display System-Level Alerts permission.

  • Where is the documentation that allows me to do this in my application?

  • Can this “system-level alert” intercept touch events? This means that I can get my application to take Android, which should stay in our building .

I like this approach because it does not allow you to turn off the phone before it is turned over (which will cause an alarm), unless, of course, the hammer is involved.

+6
source share
1 answer
  • The docs for Manifest.Permission show that SYSTEM_ALERT_WINDOW is the permission you are looking for. You must declare this permission in Manifest , and then in Dialog or any other type of Window you set this flag to WindowManager.LayoutParams.TYPE_SYSTEM_ALERT . So for Dialog it will look like this:

    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

  • Yes, he will be able to intercept touch events. System alerts, like a low battery warning, always open on top of all other applications, so any Window that you pop up will be focused, etc. Based on what you want to do with this, I would suggest that you can do something for example: a Dialog popup (like a warning about the system level) that requires a password to make it disappear.

+10
source

Source: https://habr.com/ru/post/910117/


All Articles