androidbluetoothibeacon

Bluetooth connectivity difference between beacons and smartwatches


I was investigating possibility to use android JobScheduler in combination with Background bluetoothLeScanner to get notified about specific bluetooth device in vicinity as soon as it is detected.

Problem: Documentation says, that it could take more than 15 minutes for my app to be notified about device and it doesn't seem to be realtime.

On the other hand, testing garmin smartwatches showed, that they manage to notify app with no delay.

Is there some fundamental differences between how beacons and smartwatches are implemented? Or is android preferring bluetooth advertisements from smartwatches?


Solution

  • You can detect Bluetooth Beacons within seconds on Android, but the JobScheduler is not helpful to do it quickly. The problem with the JobScheduler is that it will only let you run code every 15 minutes +/- 10 mins. So if you use it to schedule periodic scans, there may be delays.

    The alternative on Android 8+ is to use an Intent-backed scan, which will deliver scan results to a Broadcast receiver as soon as your beacon is detected. This typically delivers new detections within five seconds.

    I wrote a blog post that describes in detail how this works, and shows sample code for setting up a scan.

    The open source Android Beacon Library uses this technique to deliver fast detections.