“Write settings” permission not granted marshmallow android

狂风中的少年 提交于 2019-12-19 19:53:46

问题


<uses-permission android:name="android.permission.WRITE_SETTINGS"

I have declared above line in my manifest ,and i ask for permission on activity start but unlike other permissions,after restarting my app,it again asks for permission.When i check if permission has been granted or not,i get result that says not granted for only this permission but when i checked the same thing with other permissions ,they are granted after the user has done so.

ActivityCompat.requestPermissions(SplashScreen.this,PERMISSIONS, 1);

i check with : EasyPermissions.hasPermissions(this,PERMISSIONS)


回答1:


use this for write setting permission:

 public void settingPermission() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (!Settings.System.canWrite(getApplicationContext())) {
                Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + getPackageName()));
                startActivityForResult(intent, 200);

            }
        }
    }


来源:https://stackoverflow.com/questions/39224303/write-settings-permission-not-granted-marshmallow-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!