我们如何知道设备是否处于高精度模式.
在仅设备模式下打开Google地图时,它会要求您更改为高精度模式.我需要实现这样的事情.但我找不到任何让我们知道位置模式的API.
更新:我需要从代码中了解这一点.我需要知道设备当前是处于仅设备模式,节电模式还是高精度模式
在4.4 KITKAT
转到设置>位置
默认值仅为"设备"

按MODE键

有三种选择
根据需要进行更改
如果你想设置
mLocationRequest=LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
Run Code Online (Sandbox Code Playgroud)
如果你想知道
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
try {
locationMode = Settings.Secure.getInt(context.getContentResolver(),Settings.Secure.LOCATION_MODE);
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
return (locationMode != Settings.Secure.LOCATION_MODE_OFF && locationMode == Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); //check location mode
}else{
locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
}
Run Code Online (Sandbox Code Playgroud)
关于maven
| 归档时间: |
|
| 查看次数: |
6002 次 |
| 最近记录: |