简体   繁体   English

如何通过 ADB 命令(非 root 设备)在 Android 9 上启用/禁用 GPS 定位服务

[英]How to enable/disable GPS location services on Android 9 via ADB commands (not rooted device)

I'm doing automation for Android and for some tests I need to disable/enable location services from code.我正在为 Android 做自动化,对于一些测试,我需要从代码中禁用/启用位置服务。 I tried such commands:我试过这样的命令:

adb shell settings put secure location_providers_allowed -gps
adb shell settings put secure location_mode 0

but nothing seems to be working on Android 7...9.但在 Android 7...9 上似乎没有任何效果。

Is there any way to do that in one command?有没有办法在一个命令中做到这一点?

Thank you谢谢

Enable: adb shell settings put secure location_mode 3启用:adb shell settings put secure location_mode 3

Disable: adb shell settings put secure location_mode 0禁用:adb shell settings put secure location_mode 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式在已扎根的android上禁用/启用gps? - How to programatically disable/enable gps on rooted android? 如何通过 appium 或 adb 更改 root android 设备的 IMEI 号码? - How to change the IMEI number of a rooted android device via appium or adb? 是否有启用/禁用移动数据的 ADB 命令?(有根设备) - Is there an ADB command to enable/disable mobile data?(Rooted Device) ADB命令启用或禁用SIM卡? - ADB command to enable or disable sim card?(Rooted) 以编程方式在植根电话上启用GPS和网络位置? - Enable GPS and network location programmatically on rooted phone? 通过 adb 禁用和启用 android 触摸屏 - Disable and enable android touchscreen via adb 通过根设备中的adb调度jobScheduler任务 - Scheduling jobScheduler jobs via adb in rooted device 如何在有根 Android 7.1 电话中编辑 GPS 位置 - How to Edit GPS Location in a Rooted Android 7.1 Phone 是否真的有一种方法可以在不使用电缆的情况下将 ADB 命令发送到非 root 的 android 设备? - Is there truly a way to send ADB commands without the usage of a cable to a non-rooted android device? 如何在Rooted android设备中使用shell命令读取SMS? - How to read the SMS using shell commands In Rooted android Device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM