Skip to content Skip to sidebar Skip to footer

Enable To Monitor Beacon On Android 6.0 Using Nexus 5 Device

I am asking a follow up question to my previously asked question -> http://stackoverflow.com/questions/33607410/background-monitoring-of-eddystone-beacon-using-altbeacon-library

Solution 1:

Android 6.0 imposes two new requirements in order for apps to detect BLE Beacons:

  1. Location Services must be turned on in settings. Settings -> Location -> On. The specific mode may be either "High Accuracy" or "Device Saving". This is a new requirement that appears to be being rolled out to all firmware builds from Google. Without this on, BLE scans discover no devices.

  2. The app must be given runtime permissions by the user to ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION. You must code your app to present one of these permission requests to the user. If not granted, the app will not be able to detect BLE Beacons.

A detailed explanation of this process is in my blog post here: Is Your Beacon App Ready For Android 6.0?

Solution 2:

With Android 6.0, you now need to request location permissions at runtime in order to be able to discover beacons.

From our initial tests: if your app targets SDK < 23 (i.e., pre-Android 6.0), you will only need these permissions to detect beacons in the background. If your app targets SDK >= 23 (i.e., Android 6.0 or later), you will need these permissions to detect beacons both in the background and in the foreground. You also need to have Location enabled on your Android 6.0 device for both cases.

Google has a detailed guide on how to implement checking for and requesting runtime permissions:

http://developer.android.com/training/permissions/requesting.html

Specifically, you need either ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION. They both actually display the same message ("Allow APP_NAME to access your location?") to the user.

Post a Comment for "Enable To Monitor Beacon On Android 6.0 Using Nexus 5 Device"