How to enable screen overlay permission by default

后端 未结 5 485
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 04:38

How can I enable screen overlay permission by default while install application.

Now I facing some problem, when capture image asking run time permission some device

相关标签:
5条回答
  • 2020-12-18 05:06

    If you are using device which OS is more than 6.0 , please follow below steps

    Go to Setting --> Select Apps ---> again select setting icon in Apps ---> select draw over other apps

    Select your application and enable draw over other apps permition

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

    0 讨论(0)
  • 2020-12-18 05:10

    You don't have to enable the screen overlay permission instead before asking for permission, Show your Dialog box explaining the user why you need the permission and requesting them to accept the permission. if user chooses no don't show the permission dialog. else show him the permission dialog. This helps you to avoid the screen overlay permission.

    0 讨论(0)
  • 2020-12-18 05:16

    Send your package name inside the intent, as mentioned in the documentation.

    Input: Optionally, the Intent's data URI can specify the application package name to directly invoke the management GUI specific to the package name. For example "package:com.my.app".

    So, do something like this:

    if (!Settings.canDrawOverlays(this)) {
        int REQUEST_CODE = 101;
        Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
        myIntent.setData(Uri.parse("package:" + getPackageName()));
        startActivityForResult(myIntent, REQUEST_CODE);
    }  
    
    0 讨论(0)
  • 2020-12-18 05:16

    Add below code in your manifest

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    
    0 讨论(0)
  • 2020-12-18 05:17

    You have to leave your activity in order to get permission to draw your screen above some other activities. That is something you cannot avoid.

    In order to do that, you have to visit Settings via ACTION_MANAGE_OVERLAY_PERMISSION intent. Since you would like to have an user-friendly app, at the moment you need to ask for such permission, fire some dialog with explanation why you need that and with option for to accept and decline your requirement. On accept, fire the intent and start activity.

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