Skip to content

[Bug]: Android SDK does not drops 3s location fixes and locks activity state after stationary period (iOS works as expected) #159

Description

@soft-dev-akshay

Required Reading

  • Confirmed

SDK Version

4.1.8

Mobile operating-system(s)

  • iOS
  • Android

Device Manufacturer(s) and Model(s)

Google Pixel-5, Google Pixel-7, Google Pixel-9, Samsung

Device operating-systems(s)

12+

Build tooling versions

Android Gradle Plugin Version : 9.2.1, Gradle Version: 9.6.1

What happened?

Core Issues Summary
Inconsistent 3–5 Second Location Delivery on Android:
Our app logic relies on the SDK to emit a location update every 3 to 5 seconds so we can aggregate and persist a record every 10 seconds (~6 records per minute / 60 records per 10 minutes). On Android, the SDK skips intervals and drops location fixes, producing 15–30+ second gaps.

Activity Recognition Freezes in Previous State on Android:
When an Android device halts for longer than 3 minutes, the SDK enters the stationary state. Upon moving again (e.g., riding a bike at 30–40 km/h), the SDK continues emitting stationary/still as the active triggerActivity instead of transitioning. Conversely, when stopping, it stays locked on in_vehicle. The activity state machine remains frozen until we manually re-initialize the SDK (BGGeo.instance.ready).

Works Correctly on iOS:
Using our iOS configuration, iOS transitions activity states and streams locations dynamically as expected. The bug is isolated to the Android SDK implementation.

Questions
How do we completely disable elasticity/filters on Android so location fixes strictly fire every 3 seconds without dropping updates?

Why does the Android Activity Recognition engine freeze in stationary (or transit mode) after 3+ minute stops, requiring a re-initialization call (ready()) to resume state transitions?

iOS — Swift Config / Code

/*iOS is working correctly, pasted for ref. **/
bgGeo.ready { config in
    // Location
    config.geolocation.desiredAccuracy = kCLLocationAccuracyBest
    config.geolocation.distanceFilter = 10
    config.geolocation.pausesLocationUpdatesAutomatically = false
    config.geolocation.filter.useKalman = true
    config.geolocation.filter.kalmanProfile = .default
    
    // Activity
    config.activity.disableStopDetection = false
    config.activity.stopOnStationary = true
    
    // App
    config.app.stopOnTerminate = false
    config.app.startOnBoot = true
    
    // Logging
    config.logger.debug = false
    config.logger.logLevel = .off
}

Android — Kotlin Config / Code

BGGeo.instance.ready {
    // GEOLOCATION CONFIGURATION
    geolocation.desiredAccuracy = DesiredAccuracy.HIGH
    geolocation.distanceFilter = 0f                     /**Not to rely on distance instead get from locationUpdateInterval*/
    geolocation.disableElasticity = true                /**keep get location even fast speed*/
    geolocation.elasticityMultiplier = 0f 
    geolocation.locationUpdateInterval = 3_000
    geolocation.fastestLocationUpdateInterval = 3_000
    geolocation.stopTimeout = 3                     /**can be ignore as stopOnStationary is false*/
    geolocation.stationaryRadius = 25               
    geolocation.locationAuthorizationRequest = LocationAuthorizationRequest.ALWAYS
    geolocation.allowIdenticalLocations = true  
    geolocation.filter.policy = LocationFilterPolicy.Adjust
    geolocation.filter.useKalman = true
    geolocation.filter.kalmanProfile = KalmanProfile.Default

    // ACTIVITY RECOGNITION CONFIGURATION
    activity.activityRecognitionInterval = 3000.0  /**to get trigger activity on every 3 second*/
    activity.stopOnStationary = false  /* lets keep getting even stationary */
    activity.disableMotionActivityUpdates = false
    activity.disableStopDetection = false
    activity.motionTriggerDelay = 0
    activity.minimumActivityRecognitionConfidence = 75
    activity.triggerActivities = "in_vehicle, on_bicycle, running, on_foot, walking"
}

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions