µMax
µMax

Reputation: 347

Android security expression is thrown even after mentioned in manifest file

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 ?

Upvotes: 0

Views: 543

Answers (1)

KishuDroid
KishuDroid

Reputation: 5451

**

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

Upvotes: 1

Related Questions