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

user6265154
  • 353
  • 1
  • 6
  • 19

1 Answers1

25

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

            }
        }
    }
sneha desai
  • 886
  • 1
  • 11
  • 19
  • I ended with a similar code myself, but did you manage to get the result with `onActivityResult`? because when I pressed `Back` after giving permission, the result code I have is `RESULT_CANCELED` – yshahak Sep 22 '16 at 10:00