Android "Screen Overlay Detected" message if user is trying to grant a permission when a notification is showing

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?

enter image description here


Solution 1:

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:

Uninstall Clean Master app. I uninstalled it and problem solved

Solution 3:

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:

Select Apps select configure setting

select draw over other appsdisable culprit apps

Solution 4:

Got insights from multiple answers here and other forums .

Consolidating how I got rid of the issue :

  1. Go to Settings > Apps > (your app which is getting issue)
  2. Press on Power button till window for Power off , reboot , airplane mode comes up
  3. Hold on Power off option
  4. Select reboot in Safe mode
  5. Go to settings > apps > (your app which is getting issue)
  6. Select whichever permissions you want
  7. 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.