Is it possible to enable Location Services(GPS or Google NetworkLocation) via ADB or Terminal Emulator? I'm on a rooted Phone.
Extra Points: Is it also possible to change other system-related settings?
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.
Sign up to join this communityIs it possible to enable Location Services(GPS or Google NetworkLocation) via ADB or Terminal Emulator? I'm on a rooted Phone.
Extra Points: Is it also possible to change other system-related settings?
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
Android Location Service comes with different options:
1) High Accuracy: gps, network
Enable:
adb shell settings put secure location_providers_allowed +gps,network
Disable:
adb shell settings put secure location_providers_allowed -gps,network
2) Phone Only: gps
Enable:
adb shell settings put secure location_providers_allowed +gps
Disable: adb shell settings put secure location_providers_allowed -gps
3) Battery Saving: network
Enable:
adb shell settings put secure location_providers_allowed +network
Disable: adb shell settings put secure location_providers_allowed -network
location_providers_allowed
no longer works for Android 10 (API level 29).
Instead, you can set the location_mode
to LOCATION_MODE_HIGH_ACCURACY
with a value of 3:
adb shell settings put secure location_mode 3
NOTE: Probably won't work >v29 as this is already deprecated as the docs on Location Mode mention:
This constant was deprecated in API level 28. The preferred methods for checking location mode and listening for changes are via
LocationManager#isLocationEnabled()
andLocationManager#MODE_CHANGED_ACTION
.
Don't know what a programmatic way to do this through the shell will be once this constant disappears.