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

后端 未结 13 2410
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 14:56

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 \"Scree

相关标签:
13条回答
  • 2020-11-27 15:30

    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.

    0 讨论(0)
  • 2020-11-27 15:33

    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:

    0 讨论(0)
  • 2020-11-27 15:34

    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.

    0 讨论(0)
  • 2020-11-27 15:34

    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();
            }
        }
    }
    
    0 讨论(0)
  • 2020-11-27 15:37

    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

    0 讨论(0)
  • 2020-11-27 15:39

    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.

    0 讨论(0)
提交回复
热议问题