How to enable android.permission.SYSTEM_ALERT_WINDOW in marshmallow?

Hasnain Ahmad
Hasnain Ahmad used Ask the Experts™
I have nexus 5 android mobile. I have used this permission in my project. But it can't enable the permission in the Settings > Apps > Draw over other apps >MyApp. Permit drawing over other app is always disable. I want to programmatically enable it (showing a dialog, or without dialog), without explicitly navigating to settings and enable it by the user.
For reference AppLock is doing without prompting to user and navigating to settings.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Everything I have read indicates that if you are on Android 6.0, the user has to explicitly grant permissions (Settings > Apps> Draw over other apps) from within the system settings. There is no programmatic way around that.

For users on Android 6.0.0, all apps require manually granting SAW permission from within the system settings.

For users on devices with Android 6.0.1 (or higher), any app installed from the play store which requests SAW permissions will have it automatically granted (so the user doesn't have to do so manually from the system settings dialog), however apps which are sideloaded (IE: not from the play store) will require the user to manually grant permission to draw over other apps from within the system settings.

This is, apparently, a security decision made by google.

As an alternative, and I have no experience in this regard so I cannot vouch for it, users report that apps which target API 22 or lower have this permission automatically.

For more information, I'd refer you to the websites I found some of this information on:
The CommonsBlog

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial