I'm trying to turn location on using the following commands:
adb shell settings put secure location_providers_allowed gps,wifi,network
adb reboot
But it's neither changing the value of the variable location_providers_allowed nor turning it on under Android Settings UI after the reboot.
I tried the same command to set other variables, like mock_location, and it worked without problems. Is this variable not possible to be changed?
Android version: M
For Android 6.0
To Enable use :
For GPS : adb shell settings put secure location_providers_allowed +gps
For Network : adb shell settings put secure location_providers_allowed +network
To Disable :
GPS : adb shell settings put secure location_providers_allowed -gps
For Network : adb shell settings put secure location_providers_allowed -network
I have yet to solve this problem, but wanted to provide additional information that I feel is relevant and may help somebody else solve this.
I tried to follow this, but it was mentioned in one of the comments that:
This used to work on Android 5, but it doesn't anymore on Android 6. With or without root the setting does not change and stays the same as is configured on the system. It probably has something to do with location_providers_allowed being deprecated (developer.android.com/reference/android/provider/…) – gw0 Nov 4 '15 at 7:45
I looked into the docs for Settings.Secure location_providers_allowed and sure enough:
This constant was deprecated in API level 19. use LOCATION_MODE and MODE_CHANGED_ACTION (or PROVIDERS_CHANGED_ACTION)
I tried to set location_mode but had no effect on enabling/disabling location services.
When turning on/off location services manually through the location_providers_allowed flag is affected, not location_mode. I find it weird that the docs say it's deprecated, but it's still used and location_mode
isn't.
That's all I got.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With