Click here to Skip to main content
14,091,993 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 17 Nov 2015
Licenced CPOL

Android Marshmallow Overlay Permission

, 17 Nov 2015
Rate this:
Please Sign up or sign in to vote.
System overlay permissions in Android M


This tip explains some intricacies around system overlay permissions introduced in Android M.


Android has allowed applications to draw over all other applications using the SYSTEM_ALERT_WINDOW permission. This was allowed as long as the permission was declared in the manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="">





        android:theme="@style/AppTheme" >
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />


This technique was used by several applications that required drawing over other apps. A good example is the Facebook chatheads that float over other apps.

What Happened in M?

In Android M, the SYSTEM_ALERT_WINDOW permission was categorized as a 'dangerous' permission. This is understandable because you can imagine a transparent application intercepting your touches or inputs. So, instead of allowing the applications to use the overlay with just the manifest declaration, in Android M, the user needs to provide specific permission in Android settings for the app to draw over other apps.

This setting could be found in Settings -> Apps -> Advanced (settings icon) -> Draw over other apps

As you may be aware, Android M did introduce fine grained application permissions that the application can request for. But, as this is classified as a dangerous permission, applications cannot request this permission to the user specifically.


One possible solution is to direct the user to the above screen if the user is running Android M or above. Fortunately, Android does provide a ready made intent action that you could use to launch the above Activity.


// Check if Android M or higher
    // Show alert dialog to the user saying a separate permission is needed
    // Launch the settings activity if the user prefers
    Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);

That's it. The action ACTION_MANAGE_OVERLAY_PERMISSION directly launches the 'Draw over other apps' permission screen.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sreenivas Satish
Technical Lead
United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...

Comments and Discussions

SuggestionMissing Image Pin
Abhishek Pant17-Nov-15 18:10
professionalAbhishek Pant17-Nov-15 18:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190518.1 | Last Updated 17 Nov 2015
Article Copyright 2015 by Sreenivas Satish
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid