When I try to run the app, I get a runtime error:
Need android.permission.BLUETOOTH_SCAN permission for android.content.AttributionSource@1fe6f5d:GattService registerScanner
I can't find a way to get past this. Help.
The only thing I found so far, is that you have to ask the phone for permission to scan using BLE and it has something to do with android version 12.
The BluetoothLE extension has not yet been updated to support Android 12. As a workaround, you can add the BluetoothClient component to your project (which will add the right permissions to the project) and then use the screen's AskForPermission block to request the BLUETOOTH_SCAN permission. Usually the extension would do this all on your behalf but I have not yet had time to update the extension.
I did the 'ask for permission' and tried to continue after that in the 'if' block, but It looks like you only have to enter the permission one time since being in the 'if' block, it missed the connecting part.
Putting in the BT Client component seems to have done it.
Thanks, I'll look forward to the fix in the BLE version.
What do you mean by that? The Screen.PermissionGranted event checks whether the BLUETOOTH_CONNECT permission has been granted and then requests permission BLUETOOTH_SCAN. It should be correct like that.
Are you getting an error message? If yes, which? (Post a screenshot)
And on which Android version are you testing?
What I meant was this: (I'm not sure if this is the right way to paste my blocks)
I started with this when I first got the permission error:
I then added the 'ask for permission':
This produced the request for permission but it also didn't connect since I hadn't answered the request yet. I then answered the request and put the connect part in after the permission was granted:
This didn't work since I believe what happened was that I had gave it permission the time before so that since the connecting part was buried in the 'if' statement, it didn't run. It seems that the permission is 'already on file' and doesn't have to be repeated.
I went back to the original version, added the BT Client component, and now everything is OK.
Hi to all
I'm trying the workaround suggest from Anke and this seems work fine on Android 12, but nt work on old android version. For Example in 8.0 (samsung Galaxy S7) on start app (call screen AskForPermssion) show error like:
"Error 908:The permission BLUETOOTH_CONNECT has been denied. Please enable it in the Settings app".
Anyone have the same problem?
I'm trying to turn around the error detecting the version of anroid and skipping the woraround above, but i think is better patch the extension
i have tryed to add ACCESS_COARSE_LOCATION and recompile apk ,but the error is the same.
is there a wa to be the app compatible from 8 to 12 android version?
You could also leverage Screen1.PlatformVersion, which would need to be compared to 12.0, but it would allow you to do this in a way that doesn't require extensions. The only caveat technically would be one of the 4.2.x versions which won't coerce to numbers, but since the BLE extension requires Android 5.0 or higher this shouldn't be an issue.
It didn't work. If I am right, you only have to give it (the phone in question) permission one time. After that, it doesn't ask for it again. I think that's why nothing happens when you bury the connection process in an 'if' statement that it doesn't get to.