Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Write settings" permission not granted marshmallow android

<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)

like image 599
user6265154 Avatar asked Aug 30 '16 09:08

user6265154


People also ask

How do I check if permission is granted Android?

To check if the user has already granted your app a particular permission, pass that permission into the ContextCompat. checkSelfPermission() method. This method returns either PERMISSION_GRANTED or PERMISSION_DENIED , depending on whether your app has the permission.


1 Answers

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);

            }
        }
    }
like image 156
sneha desai Avatar answered Oct 19 '22 00:10

sneha desai