Android BLE Beacon Scanning On Different Phone Models
Solution 1:
Unfortunately, you need to stop and restart scanning to get additional callbacks. This is exactly how it is implemented in the Android Beacon Library, which stops scanning every 1.1 seconds and then immediately restarts. This makes it possible to get at one callback per cycle in cases where the operating system is not making a callback for every advertisement.
It is unclear exactly how this varies between devices and operating system versions. On the Nexus 4 with Android 4.3, scanning behavior was different for connectable BLE advertisements vs. non-connectable BLE advertisements. Connectable advertisements cause only one advertisement callback per scan cycle, whereas non-connectable advertisements receive multiple callbacks per scan cycle. This behavior may vary on other devices and OS versions, which is why cycling is necessary for wide compatibility.
On Nexus 5 devices with Android 5.0, the new scanning APIs always return multiple callbacks for each BLE advertisement from the same device, regardless of whether the advertisement is connectable or not. Nexus 4 devices with Android 5.0, however still only get one advertisement callback for connectable advertisements until the scan is stopped and restarted. This appears to be implemented at the driver level, so it is may be different for each ROM image.
Solution 2:
See this answer. The BLE spec says you don't have to get a report for each advertisment, unless you restart scanning. So some phones do and some don't. You can't rely on it.
An idiotic move in my opinion.
Post a Comment for "Android BLE Beacon Scanning On Different Phone Models"