Skip to content

Scanning for beacons using foreground service gives irregular scan intervals when device screen if off #1233

@Kavish20

Description

@Kavish20

I have configured the settings for my foreground service like below:

val settings = Settings(
scanStrategy = Settings.ForegroundServiceScanStrategy(
notification, 456
),
scanPeriods = Settings.ScanPeriods(10000L, 30000L, 10000L, 30000L),
longScanForcingEnabled = true
)
beaconManager.replaceSettings(settings)

It should wait for 30 seconds and then scan for 10 seconds in both foreground and background. Thus, one scan cycle will be of total 40 seconds.

The problem is when the app is killed and the device screen is off, the scan intervals are not regular, i.e they are not exactly 40 seconds. I have observed few cycles as low as 1 seconds and as high as 140 seconds.

Otherwise, when the device screen is on, the scan cycles are exactly at 40 seconds irrespective of the app is in the foreground or background.

The device I am using is Samsung M31 which runs on Android 12.

Is there any issue with the device hardware/software or some setting has to be configured in the library?

The library version is 2.21.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions