Screen overlay detected blocks Android permissions
This popup is caused by the manifest.PERMISSION.SYSTEM_ALERT_WINDOW permission declared by the manifest.
The are 3 categories of permissions, that developer must be aware of.:
- Normal permission - do nothing with them, just declare in the Manifest
- Vulnerable permissions - declare in Manifest and ask for permission at first time. They can be changed through system settings
- Above dangerous permissions: SYSTEM_ALERT_WINDOW and WRITE_SETTINGS belong to this category. They must be granted, but are not visible in system settings. To request for it you don't use a standard way (
int checkSelfPermission (String permission)
) but you have to checkSettings.canDrawOverlays()
orSettings.System.canWrite()
appropriately
If you don't have SYSTEM_ALERT_WINDOW permission:
- check if you have a
Toast
visible when interacting with the permissions popup. Though the Overlay Detected popup doesn't mention it, aToast
also counts as an overlay - check if any of your dependencies require it.
If you're not sure if you're using this permission, there are a couple of test cases that you can do:
Request this permission by yourself:
public class MainActivity extends AppCompatActivity {
public final static int REQUEST_CODE = 10101;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (checkDrawOverlayPermission()) {
startService(new Intent(this, PowerButtonService.class));
}
}
public boolean checkDrawOverlayPermission() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, REQUEST_CODE);
return false;
} else {
return true;
}
}
@Override
@TargetApi(Build.VERSION_CODES.M)
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE) {
if (Settings.canDrawOverlays(this)) {
startService(new Intent(this, PowerButtonService.class));
}
}
}
}Check if this or this is not your case
Check out this post to be aware, that when installing app through Play Store this permission is automatically granted (I have not checked is, therefore cannot confirm)
The permission model can be understood, just sometimes requires more digging.
Is overlay screen option is by default enable if application is downloaded from play store
Yes, you are right. SYSTEM_ALERT_WINDOW
permission is always granted, when app is installed from Play Store.
Have a look at another answer already provided on StackOverflow, that confirms that:
SYSTEM_ALERT_WINDOW - How to get this permission automatically on Android 6.0 and targetSdkVersion 23
However be advised, that it only works for Play Store. If you'd like to publish app in Samsung Store or Amazon Store, then you might have problems with that.
Also have a look at different question, where Toast
was identified as the view, that might cause similar problems on some devices:
Screen overlay detected blocks Android permissions
Hope, that this answer clears some of your concerns.
Related Topics
Swiperefreshlayout + Webview When Scroll Position Is at Top
Chaining Requests in Retrofit + Rxjava
Android Class Parcelable with Arraylist
Android Maps API V2 Draw Circle
Android - Use External Profile Image in Notification Bar Like Facebook
Refresh or Force Redraw the Fragment
Firebase: How to Set Default Notification Channel in Android App
Highlighting the Selected Item in the Listview in Android
What Is the Android UI Thread Stack Size Limit and How to Overcome It
Onkeylistener Not Working with Soft Keyboard (Android)
Send Intent from Service to Activity
My Android Camera Uri Is Returning a Null Value, But the Samsung Fix Is in Place, Help
Get Android Subscription Status, Failed with 403
How to Load HTML String in a Webview
Android Gcm (Push Notification): Device Doesn't Receive Notification If Application Is Stopped