Search code examples
androidbluetooth-lowenergybeaconaltbeacon

Altbeacon can't find beacons on Samsung S8 when location is turned off since 2.16.2


I am building an Android app that scans two types of beacon each second using the android-beacon-library:

  • iBeacon type
  • custom beacon type

I am using the library since the 2.10 release and everything works fine.

But, when I try to implement the 2.16.2, 2.16.3 and 2.16.4 releases on my Samsung S8 (which is running on Android 9), I can't scan my Beacons when I turn off the location. I did not have this issue with the 2.16.1 release.

I also tried the reference app to check if I did something wrong, but I have the same bug with the reference app.

I may specify that I only have this issue with Samsung.

Thanks.


Solution

  • Recent versions of Android require multiple levels of location authorization for an app to detect beacons (bolded items show added requirements):

    SDK 29+ (Android 10.0+)

    • Bluetooth must be turned on in settings
    • Location must be turned on in settings
    • Apps must have FINE_LOCATION permission in the manifest (COARSE_LOCATION is no longer sufficient)
    • Apps must ACCESS_BACKGROUND_LOCATION in the manifest to detect beacons when the app is not in the foreground with the screen on.
    • Apps must have dynamically obtained FINE_LOCATION permission from the user
    • Apps must have BLUETOOTH and BLUETOOTH_ADMIN permission in the manifest

    SDK 23-28 (Android 6.0-9.x)

    • Bluetooth must be turned on in settings
    • Location must be turned on in settings
    • Apps must have COARSE_LOCATION permission or FINE_LOCATION permission in the manifest
    • Apps must have BLUETOOTH and BLUETOOTH_ADMIN permission in the manifest
    • Apps must have dynamically obtained COARSE_LOCATION permission or FINE_LOCATION permission from the user

    SDK 18-22 (Android 4.3-Android 5.x)

    • Bluetooth must be turned on in settings
    • Apps must have COARSE_LOCATION permission or FINE_LOCATION permission in the manifest
    • Apps must have BLUETOOTH and BLUETOOTH_ADMIN permission in the manifest

    The above restrictions have nothing specific to do with the Android Beacon Library -- they are an operating system requirement for any Bluetooth LE detection. If you see that some devices to not enforce these requirements under some conditions, then that is most likely an implementation hole on that specific platform. The more general rules still apply.