Reputation: 61
Can't use android.permission.WRITE_SETTINGS in android manifest. im trying to turn on airplane mode by programatticaly and I can't add this permission in manifest.
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
Upvotes: 2
Views: 8101
Reputation: 560
What is the error message that you are getting? Is the app crashing when you try to open it or set the airplane settings? If you are targetting >API 23, you need to explicitly ask for permissions during runtime, this is a change from earlier versions when the permission was granted once at install time.
This link talks abou this: https://developer.android.com/reference/android/Manifest.permission.html#WRITE_SETTINGS
Upvotes: 0
Reputation: 4294
The Android docs says:
Note: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user's approval by sending an intent with action ACTION_MANAGE_WRITE_SETTINGS. The app can check whether it has this authorization by calling Settings.System.canWrite().
So you have to request the user's approval explicitly by sending an intent with action ACTION_MANAGE_WRITE_SETTINGS
.
Upvotes: 5