简体   繁体   中英

How do I grant SYSTEM_ALERT_WINDOW permission automatically on request, in my android App?

  • For context, the Android documentation says that some app classes receive the SYSTEM_ALERT_WINDOW permission automatically on request:

    • Any app that has ROLE_CALL_SCREENING and requests SYSTEM_ALERT_WINDOW automatically receives the permission. If the app misses ROLE_CALL_SCREENING, it loses permission.

    • Any app that is capturing the screen using a MediaProjection and requests SYSTEM_ALERT_WINDOW automatically receives permission, unless explicitly denied by the user. When the app stops capturing the screen, it loses permission. This use case is primarily intended for apps to stream games live.

How can I achieve this configuration to be able to obtain this permission automatically or by default?

As the documentation you quoted says, if you don't fit into one of those use cases, you can't.

It needs to be explicitly granted, and not all devices even support it.

This is because being able to draw over the screen whenever the app wants opens the door to bad behaviors, such as disguising other parts of the UI or preventing the using from using the device properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM