java在设备所有者应用程序中启用GPS
根据API documentation,设备所有者应用程序可以通过以下调用修改一些“安全设置”,特别是LOCATION_MODE:
devicePolicyManager.setSecureSetting (ComponentName admin,
String setting,
String value)
Called by profile or device owners to update Settings.Secure settings [...]
A device owner can additionally update the following settings: LOCATION_MODE
根据我的理解,LOCATION_MODE的值为int(分别为0表示位置禁用,1表示仅GPS,2表示电池节省模式,3表示高精度)
我的问题是String value
参数的类型。LOCATION_模式需要int,但API需要字符串
我错过什么了吗
# 1 楼答案
解决方案只是使用int值的字符串表示
例如,要启用“仅gps”定位模式:
[感谢@Selvin comment]
这是有道理的,因为在深入研究LOCATION_MODE的javadoc时,您可以阅读: