Android Question Need android.permission.BLUETOOTH_CONNECT

GeoffT660

Active Member
Licensed User
Longtime User
I've recently updated to B4a 12.5 and everything seems to be working great with the TargetSDK set to 26 android:targetSdkVersion="26". When I move this to android:targetSdkVersion="33" as is recommended for upcoming Google Updates, I can no longer use my bluetooth classic or BLE functionality to get Paired devices with Starter.serial1.GetPairedDevices. I have tried using the instructions to request permission from the BLE Example but still end up with the error "Need android.permission.BLUETOOTH_CONNECT". I have tried adding these lines to the manifest
Manifest Lines:
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.BLUETOOTH_SCAN)
AddPermission(android.permission.BLUETOOTH_CONNECT)
and added these lines of code to Activity.Create where I request all my permissions but still receive this error. The Wait appears to never return after the 1st permission is set.

Lines added to request permission:
Dim Permissions As List
Dim phone As Phone
If phone.SdkVersion >= 31 Then
    Permissions = Array("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT", rp.PERMISSION_ACCESS_FINE_LOCATION)
Else
    Permissions = Array(rp.PERMISSION_ACCESS_FINE_LOCATION)
End If
For Each per As String In Permissions
    rp.CheckAndRequest(per)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        ToastMessageShow("No permission: " & Permission, True)
        Return
    End If
Next
Please let me know how I might correct this
 

GeoffT660

Active Member
Licensed User
Longtime User
Thanks Erel. That solved the issue. I built this app way before B4xPages and would take forever to rebuild but use B4xPages on anything new. Wish there was a utility to help migrate to B4xPages. Thanks again and thanks for B4x!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…