WRITE_SECURE_SETTINGS permission error even when added in Manifest
Firstly, as you have read before, WRITE_SECURE_SETTINGS is NOT available to applications! So you cannot use this permission regardless whether you are on rooted or production builds.
So, if you wish to enable this setting, create your own firmware that does what you need and load that firmware on whatever devices you wish. Or, contribute your changes to existing firmware mods (e.g., Cyanogen).
Some other applications use techniques like Reflection
using Java to gain access to functions not exposed via API, you can probably try the same.
Secondly, adb remount
does not work as is with production builds unless the phone is rooted or firmware enables it by default.
How to set the Permission WRITE_SECURE_SETTINGS in android?
WRITE_SECURE_SETTINGS is not available to applications. No app outside of the system/firmware can get that permisssion.
Please check this answer
android.permission.WRITE_SECURE_SETTINGS error
WRITE_SECURE_SETTINGS
is a signatureOrSystem
permission, meaning that ordinary SDK applications cannot hold it. Only apps that are related to the firmware can hold this permission.
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.
Permission is only granted to system app
In Eclipse:
Window -> Preferences -> Android -> Lint Error Checking.
In the list find an entry with ID = ProtectedPermission
. Set the Severity to something lower than Error. This way you can still compile the project using Eclipse.
In Android Studio:
File -> Settings -> Editor -> Inspections
Under Android Lint
, locate Using system app permission
. Either uncheck the checkbox or choose a Severity lower than Error.
Android app unable to modify system settings
My resolution needed to incorporate a few different things. The solution I ended up taking was to run the app as a superuser and it seems to properly set the system settings now. Note that I am running this application on a rooted device.
First, in the Manifest, I needed to remove this line from the application tag:
android:permission="android.permission.WRITE_SECURE_SETTINGS"
Not sure of the reasoning. It looks like you can't call secure permissions within the application tag.
In my MainActivity, I added the following su call to my try statement, and added in the settings commands beneath:
Process p = Runtime.getRuntime().exec("su");
Thanks to @The-Metal-Beard for his direction!
Related Topics
Changing Text Color of Menu Item in Navigation Drawer
How to Do Circular Scrolling on Viewpager
How to Test If a Fragment View Is Visible to the User
Clarify the Firebase Connections
How to Draw Road Directions Between Two Geocodes in Android Google Map V2
How to Display Border to Imageview
Android E/Parcel﹕ Class Not Found When Unmarshalling (Only on Samsung Tab3)
How to Change Package Name in Android Studio
Android Circular Determinate Progressbar
Android Studio Create Project Template for New Projects
Cannot Find Symbol Databindingcomponent on Android Studio 3.2 Canary 16 Kotlin Project
Android Beginner Difference Between Padding and Margin
Why Does Gradle Build My Module in Release Mode When the App Is in Debug
Android. Scrolling 2 Listviews Together
Android Activity Has Leaked Window Com.Android.Internal.Policy.Impl.Phonewindow$Decorview Issue