How to enable android.permission.SYSTEM_ALERT_WINDOW in marshmallow?

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.
Hasnain AhmadAndroid App DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Philip LeBlondCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.