Android "Screen Overlay Detected" message if user is trying to grant a permission when a notification is showing
AndroidPermissionsAndroid 6.0-MarshmallowAndroid Problem Overview
I have Android Marshmallow on a Nexus 6. I am trying to fix the following problem:
If a user is trying to grant permission while a notification is showing, a "Screen overlay detected" message gets displayed and the Request Permission dialog disappears - of course the app does not get the requested permission. (Check screenshot)
I tried to fix the problem by adding "DRAW OVER OTHER APPS" permission - android.permission.SYSTEM_ALERT_WINDOW to the manifest but with no luck.
PS: I am sure the problem is caused by the notification. I do not have any app installed that overlays over other apps, I even turned off all apps with "Draw over other apps" permission in the settings. Did not help..
Anyone knows a solution to that problem?
Android Solutions
Solution 1 - Android
In the circumstance that I ran across, I was causing the problem myself. It was the result of using a Toast
to display information to the user at the same time that I was asking for permission. Both of these actions together cause this type of error.
The other answers might resolve someone else's issue. But I wanted to note that you should be cautious of causing your own overlays errors. Be careful of overlaying something in the view while simultaneously asking for permission.
Solution 2 - Android
Uninstall Clean Master app. I uninstalled it and problem solved
Solution 3 - Android
This problem appear because of some culprit application like Twilight, cleaner-master, drupe etc..
To solve this problem you have to disable screen overlay for those culprit apps.
i have moto g4 plus, and this is how i solve this problem
Go to Setting --> Select Apps ---> again select setting icon in Apps ---> select draw over other apps ---> and disable culprit apps who trouble for other apps.
what i done is checking each apps by disabling this permission and try to run my app, and i found one app this troubling overlay for other apps, so at the end i disabled only this app.
ScreenShots:
Solution 4 - Android
Got insights from multiple answers here and other forums .
Consolidating how I got rid of the issue :
- Go to Settings > Apps > (your app which is getting issue)
- Press on Power button till window for Power off , reboot , airplane mode comes up
- Hold on Power off option
- Select reboot in Safe mode
- Go to settings > apps > (your app which is getting issue)
- Select whichever permissions you want
- After Android M update , issues can come up in apps like Messenger , Whatsapp , Prisma etc.
Let me know if any issues .
Note : I am having One plus One mobile.
Solution 5 - Android
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 check Settings.canDrawOverlays() or Settings.System.canWrite() appropriately and if you not do that you will get exception like
> Unable to add window android.view.ViewRootImpl$W@1de28ad -- permission denied for this window type
1-Request this permission by yourself in your code just like given below:
public class MainActivity extends AppCompatActivity {
public final static int REQUEST_CODE = 10000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (checkDrawOverlayPermission()) {
Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show();
}
}
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)) {
Toast.makeText(this, "Permission granted", Toast.LENGTH_SHORT).show();
}
}
}
Solution 6 - Android
I just deleted my app and turned off my Nexus 6P. After turning it back on, I reinstalled the app and no longer got the "screen overlay" dialogs when giving the app permissions.
Solution 7 - Android
You must disable the overlay for all the apps you see in the list. Only this way can you modify authorizations in the app you need. I've done that in safe mode, and it worked. At the end I rebooted the phone and now it is working fine.
Solution 8 - Android
I updated my Sony Xperia Z3 (Dual Sim) to Android 6.0.1 (Marsmallow). I have been having screen overlay issues. For me i do not have Clean Master, Du Speed, or Du Booster(as the solutions i have read).
So i solved mine looking for any screen overlay apps.
A screen overlap app, is an app that you can use to access other apps on your main home screen without leaving your home screen. So for me the Screen Overlay App here in my situation was the OMNI SWIPE. So if you are facing this problem you need to calm down and check which of your app fits the definition of a screen overlay app.
locate the app and uninstall then restart your phone ..
i just finished doing this and am having a good time with the phone
Best of Luck
Solution 9 - Android
As long as Android 6.x is buggy on some devices where this "overlay alert" is displayed without any reason (on 2 to 5% of the devices according to my analytics data), the best solution is to avoid the whole permission process by defining the targetSdk to 22.
Take care that you can't downgrade the target sdk for a new version or this will induce a INSTALL_FAILED_PERMISSION_DOWNGRADE error when the user updates requiring an unisntall/install of the app.
Solution 10 - Android
solution is
remove Toast messages from onRequestPermissionsResult method
Solution 11 - Android
This happens when you have granted overlay permission to malicious apps. Go to overlay settings and disable the overlay feature on all apps that don't belong to google and you will be good to go.
Solution 12 - Android
I got this problem when installing a new app. The way I got around this problem is to manually enable the permissions for the newly installed app (before running the app). I’m pretty sure this is a problem with Android and Samsung devices in particular. Hope this helps
Solution 13 - Android
-
Delete the apps which have screen overlay like CM security, Clean Master, etc.
-
Even delete and try with Messenger (FB app) if needed.