Android KitKat及更高版本的位置_模式的可靠替代方案,以获得用户启用的位置访问度?
我想做的是: 由于在API级别19中被折旧,因此我尝试使用以获得用户对API级别19以上的位置启用的访问程度,如下所示:Android KitKat及更高版本的位置_模式的可靠替代方案,以获得用户启用的位置访问度?,android,android-4.4-kitkat,android-location,android-settings,Android,Android 4.4 Kitkat,Android Location,Android Settings,我想做的是: 由于在API级别19中被折旧,因此我尝试使用以获得用户对API级别19以上的位置启用的访问程度,如下所示: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int locationMode; try { locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOC
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int locationMode;
try {
locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
// Check if Location services in ON and if YES then make sure its in either HIGH_ACCURACY or POWER_SAVING mode (Not in GPS_ONLY)
switch (locationMode) {
case Settings.Secure.LOCATION_MODE_OFF:
//....
break;
case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
//....
break;
//....
}
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
}
问题:
现在,文件提到
注意:不要依赖settings.db中存在的此值或相应Uri的ContentObserver通知
据我所知,这意味着使用位置模式是不可靠的。那么,对于API>19,还建议使用什么来了解用户对应用程序允许的位置访问范围