自动位置设置更改会破坏地理围栏

时间:2018-12-11 19:09:07

标签: android google-play-services geofencing

我有一个使用Google Play服务地理围栏的应用程序,因此当关闭位置时,地理围栏将被删除。不幸的是,某些事情正在自动关闭位置服务设置。

这是我的手机通宵记录的一些信息(它一直坐在我的床头柜上,没有被触碰):

03:10:25|733|Pref changed w/ content://settings/global/location_global_kill_switch
03:10:25|683|SE cAN loc OFF
03:10:25|650|Pref changed w/ content://settings/secure/location_providers_allowed
03:10:13|790|SE cAN loc HIGH
03:10:13|786|Pref changed w/ content://settings/global/network_recommendations_enabled
03:10:13|772|SE cAN loc HIGH
03:10:13|768|Pref changed w/ content://settings/global/location_global_kill_switch
03:10:13|707|SE cAN loc HIGH
03:10:13|683|Pref changed w/ content://settings/secure/location_providers_allowed
00:06:38|76|SE cAN loc OFF

“ Pref已更改”行来自ContentObserver.onChange uri。这是获取另一条日志行的loc设置的代码:

val locationManager: LocationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager
val gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
val networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
return if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)) {
        Loc.DENIED
} else if (gpsEnabled) {
        Loc.HIGH
} else if (networkEnabled) {
        Loc.LOW
} else {
        Loc.OFF
}

从该日志记录中,您可以看到自己更改的设置以及它们如何影响位置服务设置。

为了使我的问题尽可能广泛-如何保护我的地理围栏?

0 个答案:

没有答案