connectivity-samples icon indicating copy to clipboard operation
connectivity-samples copied to clipboard

Missing permissions in BluetoothLeGatt example

Open VeloSteve opened this issue 3 years ago • 2 comments

I was mystified by scans which appeared to be running but found no devices. There were no error messages or requests for permissions.

I eventually added

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

to the manifest and it started working. That really should be in the repository versions.

As a relative beginner I didn't know whether to blame API versions, deprecated code, gradle versions (Android Studio told me to upgrade to 7.0.3), or what, so it took hours to find this.

I'm using Android Studio 20.3.1 patch 3, and installing on a Pixel 3aXL.

VeloSteve avatar Dec 05 '21 22:12 VeloSteve

@VeloSteve Did you find any soln?

pritsawa avatar Mar 31 '22 03:03 pritsawa

The workaround was simply to put those 3 lines in AndroidManifest.xml. I just think they should be included in the demo code. Actually, I now have the lines below. I'm still learning, so this may not be the ideal set, but it works.

`

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" />`

VeloSteve avatar Apr 01 '22 15:04 VeloSteve