Does not work on Android Marshmallow
Opened this issue · 4 comments
DreierF commented
To get this working on android 6 you have to add the following permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
CristinaNicolae commented
It's not really working on my phone. Any updates?
rishihegde commented
Hi,
Can you guide me on how to extend the code to automatically connect to a particular Bluetooth device after pairing?
Josep313 commented
ArrayList returns empty after scanning on Nexus 5 (Android Marshmallow)
jayanthchandra commented
Guys, Add this code and call checkBluetoothPermissions()
before startDiscovery()
,
public void checkBluetoothPermissions(){
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP){
int permissionCheck = this.checkSelfPermission("Manifest.permission.ACCESS_FINE_LOCATION");
permissionCheck += this.checkSelfPermission("Manifest.permission.ACCESS_COARSE_LOCATION");
if (permissionCheck != 0) {
this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1001); //Any number
}
}else{
Log.d(TAG, "checkBTPermissions: No need to check permissions. SDK version < LOLLIPOP.");
}
}