Я создал Геозону со следующим кодом:
private fun createOnlineGeofence(currentLocation: GeoPoint){
val geofenceId = this.resources.getString(R.string.leaving_area_geofence_id)
/** Create Geofence */
val geofence = Geofence.Builder().apply {
setRequestId(geofenceId)
setCircularRegion(currentLocation.latitude, currentLocation.longitude, 400f)
setExpirationDuration(Geofence.NEVER_EXPIRE)
setTransitionTypes(Geofence.GEOFENCE_TRANSITION_EXIT)
setNotificationResponsiveness(300000)
}.build()
val geofenceRequest = GeofencingRequest.Builder().apply {
addGeofence(geofence)
}.build()
val pendingIntent: PendingIntent by lazy {
val intent = Intent(mContext.applicationContext, GeofenceBroadcastReceiverTesting::class.java)
intent.putExtra("type", "online")
PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
geofencingClient.addGeofences(geofenceRequest, pendingIntent)
}
}
Могу ли я обратиться к requestId
Геозоны в другой функции, чтобы проверить, активна ли она?