0

I'm using Android Studio 1.3.2 on win7(64-bit) machine, developing application with kitkat (API level 23).

I'm trying to set brightness using seekbar control and have mentioned permission in manifest file as below

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

Now i'm getting the below exception

java.lang.SecurityException: com.sam.shmiandan.androidbrightness was not granted  this permission: android.permission.WRITE_SETTINGS

How can I solve below error ?

AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
µMax
  • 337
  • 1
  • 6
  • 15

1 Answers1

1

**

Note : You are using API 23 level which is not Kitkat.

**

To use WRITE_SETTINGS, based on the docs:

  1. Have the element in the manifest as normal..

    Call Settings.System.canWrite() to see if you are eligible to write out settings.

  2. If canWrite() returns false, start up the ACTION_MANAGE_WRITE_SETTINGS activity so the user can agree there to allow your app to actually write to settings.

  3. IOW, writing to settings is now a double-opt-in (agree to install, agree separately in Settings to allow), akin to device admin APIs, accessibility services, etc.

Also note that I have not tried using these yet — this is based on research that I did yesterday on Android 6.0 changes

Reference : Can't get WRITE_SETTINGS permission

Community
  • 1
  • 1
KishuDroid
  • 5,411
  • 4
  • 30
  • 47