Can't get WRITE_SETTINGS permission
To use WRITE_SETTINGS
, based on the docs:
Have the
<uses-permission>
element in the manifest as normal.Call
Settings.System.canWrite()
to see if you are eligible to write out settings.If
canWrite()
returnsfalse
, start up theACTION_MANAGE_WRITE_SETTINGS
activity so the user can agree there to allow your app to actually write to settings.
In other words, 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.
Is android.permission.WRITE_SETTINGS only granted to system apps?
As stated by user passsy in the stackoverflow question provided by Brian, android.permission.WRITE_SETTINGS
has a android:protectionLevel
of "signature"
, which makes the permission unavailable for use in user applications since API level 23.
See https://developer.android.com/guide/topics/manifest/permission-element#plevel for the description of protection levels for permissions.
The best way to check for write_settings permission
Yes, you can.
These two verifications do practically the same thing, except that you need the Android Support dependency in order to use ContextCompat
, whereas Settings.System
is part of the default Android SDK. Note that Context
class can check for permissions too.
By the way, electing one way as the best way to check for permissions is rather opinion-based, and it's not something the stackoverflow community fancies too much. You should compare the possibilities and choose the one that fits you best.
but this way is very bad 'cause have to check every time what is Android version. :(
You'll get used to it.
Related Topics
Create Custom Notification, Android
Is There Any Reason to Use the Support.V4 Library in Android
How to Pass Integer from One Activity to Another
Recognizing Multiple Keywords Using Pocketsphinx
Out of Memory Error with Bitmap
Why Do I Get "Unresolved Reference" Error for My View's Name/Id When I Type It in Kotlin
Build and Install Unsigned APK on Device Without the Development Server
Remove Listview Items in Android
How to Request Permissions from a Service in Android Marshmallow
How to Create Edittext Accepts Alphabets Only in Android
How to Display Album Art Using Mediastore.Audio.Albums.Album_Art
Detecting Whether a Headset Is Plugged into an Android Device or Not
Adt Will Not Allow Creation of Android Activity
Permission Is Only Granted to System App
Difficulties with Calling an Android Ndk Function from Directly Delphi
How to Take a Screenshot of a Current Activity and Then Share It