c0d3er
c0d3er

Reputation: 61

android.permission.WRITE_SETTINGS cant use in manifest

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

Answers (2)

shiredude95
shiredude95

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

Hong Duan
Hong Duan

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

Related Questions