flutter_background_geolocation
flutter_background_geolocation copied to clipboard
startGeofence on Android don't fire events enter/dwell/exit
Your Environment
- Plugin version: ^4.13.3
- Platform: Android
- OS version: 12 (API 32)
- Device manufacturer / model: Emulator (Pixel XL API 32)
- Flutter info (
flutter doctor):
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.7, on macOS 13.6 22G120 darwin-arm64, locale it-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.83.1)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!
- Plugin config:
bg.BackgroundGeolocation.ready(bg.Config(
debug: true,
logLevel: bg.Config.LOG_LEVEL_DEBUG,
reset: true,
locationAuthorizationRequest: 'Always',
desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
distanceFilter: 100000,
stopOnTerminate: false,
enableHeadless: true,
startOnBoot: true,
geofenceModeHighAccuracy: true,
disableLocationAuthorizationAlert: true,
disableMotionActivityUpdates: true,
foregroundService: true,
allowIdenticalLocations: false,
showsBackgroundLocationIndicator: false,
maxRecordsToPersist: 25,
stopTimeout: 1,
))
.then((bg.State state) async {
if (!state.enabled) {
await bg.BackgroundGeolocation.startGeofences();
await bg.BackgroundGeolocation.getCurrentPosition();
}
});
Expected Behavior
Geofence events (enter, dwell, exit) fired when the device is inside/outside.
Actual Behavior
The code works only by calling await bg.BackgroundGeolocation.getCurrentPosition(); in a loop; otherwise, no event is called. Same behavior if the app is killed. The same code works with iOS.
Steps to Reproduce
- Start the plugin with
await bg.BackgroundGeolocation.startGeofences(); - Add a Geofence with a push when you are inside (enter/dwell) and outside (exit)
- Try to move on your map.
Context
I'd like to keep the user's position updated only when a geofence event is fired.
Debug logs
Logs
10-19 18:48:47.435 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/location
10-19 18:48:47.436 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/motionchange
10-19 18:48:47.436 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/activitychange
10-19 18:48:47.436 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/geofenceschange
10-19 18:48:47.437 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/geofence
10-19 18:48:47.437 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/heartbeat
10-19 18:48:47.437 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/http
10-19 18:48:47.437 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/schedule
10-19 18:48:47.437 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/connectivitychange
10-19 18:48:47.438 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/enabledchange
10-19 18:48:47.438 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/providerchange
10-19 18:48:47.438 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/powersavechange
10-19 18:48:47.438 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/notificationaction
10-19 18:48:47.438 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a] com.transistorsoft/flutter_background_geolocation/events/authorization
10-19 18:48:47.438 13403 13531 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
10-19 18:48:47.438 13403 13531 I TSLocationManager: ✅ Google Play Services: connected (version code:12451000)
10-19 18:48:47.438 13403 13531 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:47.438 13403 13531 I TSLocationManager: ║ TSLocationManager version: 3.5.2 (431)
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╟─ Google sdk_gphone64_arm64 @ 12 (flutter)
10-19 18:48:47.438 13403 13531 I TSLocationManager: {
10-19 18:48:47.438 13403 13531 I TSLocationManager: "activityRecognitionInterval": 10000,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "allowIdenticalLocations": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "authorization": {},
10-19 18:48:47.438 13403 13531 I TSLocationManager: "autoSync": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "autoSyncThreshold": 0,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "backgroundPermissionRationale": {
10-19 18:48:47.438 13403 13531 I TSLocationManager: "title": "Vorremmo accedere alla tua posizione",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "message": "Usiamo il GPS in background per sapere quando entri in ufficio.",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "positiveAction": "Accetto",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "negativeAction": "Annulla"
10-19 18:48:47.438 13403 13531 I TSLocationManager: },
10-19 18:48:47.438 13403 13531 I TSLocationManager: "batchSync": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "configUrl": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "debug": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "deferTime": 0,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "desiredAccuracy": -1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "desiredOdometerAccuracy": 100,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "disableAutoSyncOnCellular": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "disableElasticity": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "disableLocationAuthorizationAlert": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "disableMotionActivityUpdates": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "disableProviderChangeRecord": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "disableStopDetection": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "distanceFilter": 100000,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "elasticityMultiplier": 1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "enableHeadless": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "enableTimestampMeta": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "extras": {},
10-19 18:48:47.438 13403 13531 I TSLocationManager: "fastestLocationUpdateInterval": -1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "foregroundService": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "geofenceInitialTriggerEntry": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "geofenceModeHighAccuracy": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "geofenceProximityRadius": 1000,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "geofenceTemplate": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "headers": {},
10-19 18:48:47.438 13403 13531 I TSLocationManager: "headlessJobService": "com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "heartbeatInterval": -1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "httpRootProperty": "location",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "httpTimeout": 60000,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "isMoving": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "locationAuthorizationRequest": "Always",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "locationTemplate": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "locationTimeout": 60,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "locationUpdateInterval": 1000,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "locationsOrderDirection": "ASC",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "logLevel": 4,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "logMaxDays": 3,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "maxBatchSize": -1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "maxDaysToPersist": 1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "maxMonitoredGeofences": 97,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "maxRecordsToPersist": 25,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "method": "POST",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "minimumActivityRecognitionConfidence": 75,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "motionTriggerDelay": 0,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "notification": {
10-19 18:48:47.438 13403 13531 I TSLocationManager: "layout": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "title": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "text": "Location Service activated",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "color": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "channelName": "TSLocationManager",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "channelId": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "smallIcon": "drawable\/ic_push_icon",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "largeIcon": "mipmap\/launcher_icon",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "priority": -1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "sticky": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "strings": {},
10-19 18:48:47.438 13403 13531 I TSLocationManager: "actions": []
10-19 18:48:47.438 13403 13531 I TSLocationManager: },
10-19 18:48:47.438 13403 13531 I TSLocationManager: "params": {},
10-19 18:48:47.438 13403 13531 I TSLocationManager: "persist": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "persistMode": 2,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "schedule": [],
10-19 18:48:47.438 13403 13531 I TSLocationManager: "scheduleUseAlarmManager": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "speedJumpFilter": 300,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "startOnBoot": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "stationaryRadius": 25,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "stopAfterElapsedMinutes": 0,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "stopOnStationary": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "stopOnTerminate": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "stopTimeout": 1,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "url": "",
10-19 18:48:47.438 13403 13531 I TSLocationManager: "useSignificantChangesOnly": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "enabled": true,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "schedulerEnabled": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "trackingMode": 0,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "odometer": 0,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "isFirstBoot": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "didLaunchInBackground": false,
10-19 18:48:47.438 13403 13531 I TSLocationManager: "didDeviceReboot": false
10-19 18:48:47.438 13403 13531 I TSLocationManager: }
10-19 18:48:47.438 13403 13531 I TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:47.438 13403 13531 I TSLocationManager: ║ DEVICE SENSORS
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╟─ ✅ ACCELEROMETER: {Sensor name="Goldfish 3-axis Accelerometer", vendor="The Android Open Source Project", version=1, type=1, maxRange=39.300102, resolution=2.480159E-4, power=3.0, minDelay=10000}
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╟─ ✅ GYROSCOPE: {Sensor name="Goldfish 3-axis Gyroscope", vendor="The Android Open Source Project", version=1, type=4, maxRange=16.46, resolution=0.001, power=3.0, minDelay=10000}
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╟─ ✅ MAGNETOMETER: {Sensor name="Goldfish 3-axis Magnetic field sensor", vendor="The Android Open Source Project", version=1, type=2, maxRange=2000.0, resolution=0.5, power=6.7, minDelay=10000}
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╟─ ⚠️ SIGNIFICANT_MOTION: none. Motion-detection system performance will be degraded
10-19 18:48:47.438 13403 13531 I TSLocationManager: ╚═════════════════════════════════════════════
10-19 18:48:47.438 13403 13531 D TSLocationManager: [c.t.l.logger.LoggerFacade$a a]
10-19 18:48:47.438 13403 13531 D TSLocationManager: 🎾 Start monitoring connectivity changes
10-19 18:48:47.449 13403 13534 D TSLocationManager: [c.t.l.l.TSSQLiteAppender$c run]
10-19 18:48:47.449 13403 13534 D TSLocationManager: ℹ️ Cleared logs older than 72 hours
10-19 18:48:47.479 13403 13533 D TSLocationManager: [c.t.l.http.HttpService a]
10-19 18:48:47.479 13403 13533 D TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:47.479 13403 13533 D TSLocationManager: ║ 📶 Connectivity change: connected? true
10-19 18:48:47.479 13403 13533 D TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:47.479 13403 13523 I TSLocationManager: [c.t.l.p.TSProviderManager startMonitoring]
10-19 18:48:47.479 13403 13523 I TSLocationManager: 🎾 Start monitoring location-provider changes
10-19 18:48:47.496 13403 13532 I TSLocationManager: [c.t.l.g.TSGeofenceManager start]
10-19 18:48:47.496 13403 13532 I TSLocationManager: 🎾 Start monitoring geofences
10-19 18:48:47.498 13403 13523 D TSLocationManager: [c.t.l.a.BackgroundGeolocation a]
10-19 18:48:47.498 13403 13523 D TSLocationManager: 🔴 Cleared callbacks
10-19 18:48:47.510 13403 13531 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO prune]
10-19 18:48:47.510 13403 13531 D TSLocationManager: ℹ️ PRUNE -1 days
10-19 18:48:47.584 13403 13403 D TSLocationManager: [c.t.l.l.LifecycleManager onCreate] ☯️ onCreate
10-19 18:48:47.584 13403 13403 D TSLocationManager: [c.t.l.l.LifecycleManager onStart] ☯️ onStart
10-19 18:48:47.584 13403 13403 D TSLocationManager: [c.t.l.l.LifecycleManager onResume] ☯️ onResume
10-19 18:48:47.609 13403 13532 I TSLocationManager: [c.t.l.BootReceiver b]
10-19 18:48:47.609 13403 13532 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:47.609 13403 13532 I TSLocationManager: ║ BootReceiver: com.hidden.app
10-19 18:48:47.609 13403 13532 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:47.609 13403 13532 I TSLocationManager: ╟─ android.intent.action.MY_PACKAGE_REPLACED
10-19 18:48:47.610 13403 13532 D TSLocationManager: [c.t.l.g.TSGeofenceManager d] ℹ️ Persist monitored geofences: []
10-19 18:48:48.953 13403 13403 D TSLocationManager: [c.t.f.b.streams.StreamHandler onListen] providerchange
10-19 18:48:48.954 13403 13403 D TSLocationManager: [c.t.f.b.streams.StreamHandler onListen] location
10-19 18:48:48.955 13403 13403 D TSLocationManager: [c.t.f.b.streams.StreamHandler onListen] geofence
10-19 18:48:48.961 13403 13403 D TSLocationManager: [c.t.l.adapter.TSConfig e] ℹ️ Persist config, dirty: [backgroundPermissionRationale, backgroundPermissionRationale.title, backgroundPermissionRationale.message, backgroundPermissionRationale.positiveAction, backgroundPermissionRationale.negativeAction, debug, desiredAccuracy, disableLocationAuthorizationAlert, disableMotionActivityUpdates, distanceFilter, enableHeadless, extras, geofenceModeHighAccuracy, headers, headlessJobService, logLevel, maxRecordsToPersist, notification, notification.smallIcon, notification.largeIcon, params, schedule, startOnBoot, stopOnTerminate, stopTimeout]
10-19 18:48:48.966 13403 13403 D TSLocationManager: [c.t.l.u.LocationAuthorization withBackgroundPermission]
10-19 18:48:48.966 13403 13403 D TSLocationManager: ℹ️ LocationAuthorization: Permission granted
10-19 18:48:48.971 13403 13531 I TSLocationManager: - Enable: true → true, trackingMode: 0
10-19 18:48:48.974 13403 13531 D TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges]
10-19 18:48:48.974 13403 13531 D TSLocationManager: 🎾 Start monitoring connectivity changes
10-19 18:48:48.974 13403 13531 D TSLocationManager: [c.t.l.device.DeviceSettings startMonitoringPowerSaveChanges]
10-19 18:48:48.974 13403 13531 D TSLocationManager: 🎾 Start monitoring powersave changes
10-19 18:48:48.976 13403 13531 I TSLocationManager: [c.t.l.service.HeartbeatService stop]
10-19 18:48:48.976 13403 13531 I TSLocationManager: 🔴 Stop heartbeat
10-19 18:48:48.992 13403 13403 I TSLocationManager: [c.t.l.l.TSLocationManager a]
10-19 18:48:48.992 13403 13403 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:48.992 13403 13403 I TSLocationManager: ║ motionchange LocationResult: 1 (198905ms old)
10-19 18:48:48.992 13403 13403 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:48.992 13403 13403 I TSLocationManager: ╟─ 📍 Location[fused 38.855215,16.614975 hAcc=5.0 et=+1d21h45m14s932ms alt=0.0 vAcc=0.5 vel=0.0 sAcc=0.5 {Bundle[{}]}], time: 1697733911825
10-19 18:48:49.109 13403 13403 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 5.0
10-19 18:48:49.131 13403 13403 D TSLocationManager: [c.t.l.u.LocationAuthorization withPermission]
10-19 18:48:49.131 13403 13403 D TSLocationManager: ℹ️ LocationAuthorization: Permission granted
10-19 18:48:49.145 13403 13403 D TSLocationManager: [c.t.l.g.TSGeofenceManager$e a] ℹ️ GeofencingClient addGeofences SUCCESS
10-19 18:48:49.145 13403 13403 D TSLocationManager: [c.t.l.g.TSGeofenceManager d] ℹ️ Persist monitored geofences: [3]
10-19 18:48:49.145 13403 13403 D TSLocationManager: [c.t.l.g.TSGeofenceManager$e a]
10-19 18:48:49.145 13403 13403 D TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:49.145 13403 13403 D TSLocationManager: ║ TSGeofenceManager monitoring 1/1
10-19 18:48:49.145 13403 13403 D TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:49.145 13403 13403 D TSLocationManager: ╟─ 🎾 3
10-19 18:48:49.145 13403 13403 D TSLocationManager: ╚═════════════════════════════════════════════
10-19 18:48:49.195 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:49.195 13403 13403 D TSLocationManager: 🎾 start [LocationRequestService startId: 1, eventCount: 1]
10-19 18:48:49.197 13403 13531 I TSLocationManager: [c.t.l.l.SingleLocationRequest startUpdatingLocation]
10-19 18:48:49.197 13403 13531 I TSLocationManager: 🔵 [SingleLocationRequest start, action: 1, requestId: 1]
10-19 18:48:49.433 13403 13531 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:49.433 13403 13531 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 1, eventCount: 0, sticky: true]
10-19 18:48:53.792 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:53.792 13403 13403 D TSLocationManager: 🎾 1:1 [LocationRequestService startId: 2, eventCount: 1]
10-19 18:48:53.798 13403 13531 I TSLocationManager: [c.t.l.l.TSLocationManager a]
10-19 18:48:53.798 13403 13531 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:53.798 13403 13531 I TSLocationManager: ║ motionchange LocationResult: 1 (24ms old)
10-19 18:48:53.798 13403 13531 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:53.798 13403 13531 I TSLocationManager: ╟─ 📍 Location[fused 38.855215,16.614975 hAcc=5.0 et=+1d21h48m38s618ms alt=0.0 vAcc=0.5 vel=0.0 sAcc=0.5 {Bundle[{}]}], time: 1697734133770
10-19 18:48:53.798 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:53.798 13403 13403 D TSLocationManager: 🎾 start [GeofencingService startId: 1, eventCount: 1]
10-19 18:48:53.799 13403 13531 D TSLocationManager: [c.t.l.g.TSGeofenceManager setLocation] isMoving: false | stateChanged: false | timerExpired: true | elapsed: 221945 | d: 0.0
10-19 18:48:53.799 13403 13531 I TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
10-19 18:48:53.799 13403 13531 I TSLocationManager: 🔵 Acquired motionchange position, isMoving: false
10-19 18:48:53.799 13403 13531 D TSLocationManager: [c.t.l.l.TSLocationManager a] Median accuracy: 5.0
10-19 18:48:53.806 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService b]
10-19 18:48:53.806 13403 13403 D TSLocationManager: 🎾 STOP [LocationRequestService startId: 3, eventCount: 2]
10-19 18:48:53.806 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:53.806 13403 13403 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 3, eventCount: 1, sticky: false]
10-19 18:48:53.818 13403 13531 D TSLocationManager: [c.t.l.g.TSGeofenceManager setLocation] isMoving: false | stateChanged: false | timerExpired: true | elapsed: 221945 | d: 0.0
10-19 18:48:53.818 13403 13531 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:53.818 13403 13531 D TSLocationManager: ⚙️︎ FINISH [LocationRequestService startId: 2, eventCount: 0, sticky: false]
10-19 18:48:53.851 13403 13532 I TSLocationManager: [c.t.l.s.GeofencingService a]
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:53.851 13403 13532 I TSLocationManager: ║ Geofencing Event: ENTER
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╟─ 3
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╚═════════════════════════════════════════════
10-19 18:48:53.853 13403 13532 D TSLocationManager: [c.t.l.g.TSGeofenceManager setLocation] isMoving: false | stateChanged: false | timerExpired: true | elapsed: 221945 | d: 0.0
10-19 18:48:53.870 13403 13532 I TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
10-19 18:48:53.870 13403 13532 I TSLocationManager: ✅ INSERT: 85177b75-222f-488a-8a07-febc2bb2697f
10-19 18:48:53.883 13403 13532 D TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO shrink]
10-19 18:48:53.883 13403 13532 D TSLocationManager: ℹ️ SHRINK: 25
10-19 18:48:53.889 13403 13532 D TSLocationManager: [c.t.l.service.AbstractService a]
10-19 18:48:53.889 13403 13532 D TSLocationManager: ⚙️︎ FINISH [GeofencingService startId: 1, eventCount: 0, sticky: false]
10-19 18:48:54.053 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService f]
10-19 18:48:54.053 13403 13403 D TSLocationManager: ⚙️︎ LocationRequestService.stopSelfResult(3): true
10-19 18:48:54.054 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService onDestroy]
10-19 18:48:54.054 13403 13403 D TSLocationManager: 🔴 LocationRequestService stopped
10-19 18:48:54.094 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService f]
10-19 18:48:54.094 13403 13403 D TSLocationManager: ⚙️︎ GeofencingService.stopSelfResult(1): true
10-19 18:48:54.094 13403 13403 D TSLocationManager: [c.t.l.service.AbstractService onDestroy]
10-19 18:48:54.094 13403 13403 D TSLocationManager: 🔴 GeofencingService stopped
@christocracy, could you help me? Thanks
I see a geofence fired in your logs:
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╔═════════════════════════════════════════════
10-19 18:48:53.851 13403 13532 I TSLocationManager: ║ Geofencing Event: ENTER
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╠═════════════════════════════════════════════
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╟─ 3
10-19 18:48:53.851 13403 13532 I TSLocationManager: ╚═════════════════════════════════════════════
It happens only when the app is in the foreground and the await bg.BackgroundGeolocation.getCurrentPosition() is called, but no event is fired without the call. In the console log above, you'll see only the ENTER event, but when the device goes out of the geofence, no "EXIT" event is fired.
Geofences rarely work with simulated location, if that's what you're trying to do.
Geofences are best tested outside with a real device with real movement.
I have the same results with real devices, but only using Android: iOS works.
So, I replaced startGeofences() with start() (only on Android), and now it works in the foreground: when the app is in the background or killed, no geofence event is fired.
See https://dontkillmyapp.com
Restart your device.
Shouldn't Android fire the geofences also with a killed app?
Shouldn't Android fire the geofences also with a killed app?
Yes, it does. Enable debug: true and you will hear the plugin debug sound effect when a geofence event occurs (regardless if terminated).
I have debug: true, but no debug sound happens when the app is terminated.
I suggest you try the /example app in this repo. Long-press on map to add geofences.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.