Missing permission request
Hi, i just run project on Android 7 and it didn't work( didn't show any ~BLE devices during scan) because of Binder exception:
W/Binder: Caught a RuntimeException from the binder stub implementation. java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results at android.os.Parcel.readException(Parcel.java:1620) at android.os.Parcel.readException(Parcel.java:1573) at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:883) at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:375) at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56) at android.os.Binder.execTransact(Binder.java:453)
After manually adding of :
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
and manually turning on location permission thru app settings, application started to work and show BLE devices around.
Conclusion: project missing Location permission and check for granted permissions on Android 6+
Here is the source code with the manifest file fixed and the request to access permissions in the onCreate(). android-BluetoothLeGatt-master 2.zip
Thanks for that fix, I'm a newbie trying to get my head around BLE data transfer. This has helped a lot!
Awesome!
Had the same issue and that fixed it, thanks a lot :)
I added the permission in manifest and turned on the location,but still it doesnt display any ble device name
GOOGLE. My dude. Please freaking fix your project and add: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
GOOGLE. My dude. Please freaking fix your project and add:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Adding the permission will not be enough, because this is a runtime permission and the target SDK is 27. They either have to lower the targetSDKVersion or add some code to ask for this runtime permission.
Which this PR seems to contain already: https://github.com/googlesamples/android-BluetoothLeGatt/pull/53/files
So yeah, Google! Just have look at this PR and merge it.