I want to turn on airplane mode through the code and turn off bluetooth, wifi and mobile data. First, execute this in the console:
adb shell pm grant com.package.name android.permission.WRITE_SECURE_SETTINGS
Second, turn on airplane mode from code:
//Set radios cell,wifi,bluetooth witch will be off
Settings.Global.putString(requireContext().contentResolver,
Settings.Global.AIRPLANE_MODE_RADIOS,
"${Settings.Global.RADIO_CELL},
${Settings.Global.RADIO_WIFI},
${Settings.Global.RADIO_BLUETOOTH}"
)
Settings.Global.putInt(
requireContext().contentResolver,
Settings.Global.AIRPLANE_MODE_ON, 1
)
But in the settings, I see that only wifi is turned off, bluetooth and mobile date are still on. Why can't I turn them all off from the code?