4

After the update (Android 6) my nexus 5, my running application not able to scan(find) the any bluetooth device. getBondedDevices() to get paired devices list working fine.

I have also test many sample code and application (I have put link below) of bluetooth functionality. all have the same problem, it's not able to find the bluetooth device.

But yes I have found only one application on play store which is working and it able to discover/scan the bluetooth device.

Not working apps on Android 6 (Nexus 5) I have tested many app like, bluetrem, sample code by Android Developer and many more.

Working app Bluetooth 4.0 Scanner https://play.google.com/store/apps/details?id=com.bluemotionlabs.bluescan

Is Any one know what is the problem, is there any changes required on code to make compatible with Android 6

Jørgen R
  • 10,568
  • 7
  • 42
  • 59
Mandy
  • 419
  • 4
  • 6
  • 1
    issue seems to be the way we attach callback listener. assuming it is a BLE device. check "Improved Bluetooth Low Energy Scanning" section if that is the case : http://developer.android.com/about/versions/marshmallow/android-6.0.html#ble-scanning – binaryKarmic Oct 28 '15 at 15:45
  • Did you resolve the problem? – bendaf Jan 03 '16 at 00:12

3 Answers3

5

At least in Android 6.0 November 1, 2015 security patch, you not only need ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions but also need the location service actually turned on in order for Bluetooth scan to work.

I verified this in my app and a bunch of other BLE apps in Play Store, including Bluetooth 4.0 Scanner.

This means we have to make sure location is on before starting a scan, otherwise it will fail silently.

Arrix
  • 2,721
  • 20
  • 19
4

It works, this is a solution, try to turn on GPS after put ACCESS_FILE_LOCATION or ACCESS_COARSE_LOCATION and after ask the runtime permission

Tr4K4r
  • 41
  • 3
1

As it's in the change list of Android 6, your app must now have the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions for some bluetooth calls. Please check if you have it.

bendaf
  • 2,981
  • 5
  • 27
  • 62