Bluetooth discover/scan code not working after update Android 6 on my Nexus 5

3k Views Asked by At

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

3

There are 3 best solutions below

0
bendaf On

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.

0
Arrix On

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.

1
Tr4K4r On

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