I am working for an application which uses BLE technology for pairing and IOT device and uses precises location to perform some specific task related to application requirements
Now, on Android 12 some device (I tested on SAMSUNG SM-M21) it ended up in error
location permission missing (code 3)
whereas in another device like Realme, Mi it works fine as expected
After referring to the article https://developer.android.com/guide/topics/connectivity/bluetooth/permissions
I already added these permission in the Manifest
<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"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
I am already requesting permission at runtime from user
If any more information is needed, please let me know. I will update the question accordingly.
I solved it by adding this to manifest
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" />
and at code level added a condition which add extra permission runtime only for Android 12 and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
//requesting permission only for Android 12 and above
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.BLUETOOTH_ADVERTISE,
}
Note: other permissions also as normally requested