2

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" />
c0d3er
  • 51
  • 2
  • 5

2 Answers2

5

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.

Hong Duan
  • 4,234
  • 2
  • 27
  • 50
0

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

shiredude95
  • 560
  • 3
  • 7