I have written a xamarin forms app which uses the Plugin.BLE NuGet package to scan and connect to ble devices. It was working/debugging flawlessly on my phone until it(my phone) updated to Android 12.0 - API 31. I am using the basic vanilla implementation from the plugin:
adapter.DeviceDiscovered += (s,a) => deviceList.Add(a.Device);
await adapter.StartScanningForDevicesAsync();
I have found that Android 12 requires different runtime permissions ([https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android11-or-lower][1]) and I have tried to accomodate them in the manifest file:
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="Rep_001.Android" android:theme="@style/MainTheme"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android11-or-lower
but alas I am having no luck. I am thinking that I need to ask the user for scan and connect privileges at runtime but I am not sure how to do that as Xamarin.Essentials does not have bluetooth permissions requests.