Hello,
I don't understand since the Android 13 update on my phone my application no longer wants to work, I have this error message and can't find the solution?
I think it's a permission problem of the nearby device.
I don't understand since the Android 13 update on my phone my application no longer wants to work, I have this error message and can't find the solution?
I think it's a permission problem of the nearby device.
B4X:
b4xmainpage_initialize (java line: 662)
java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@89ab1bba: enable
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.bluetooth.BluetoothManagerService.checkPermissionForDataDelivery(BluetoothManagerService.java:3112)
at com.android.server.bluetooth.BluetoothManagerService.checkConnectPermissionForDataDelivery(BluetoothManagerService.java:3130)
at com.android.server.bluetooth.BluetoothManagerService.checkBluetoothPermissions(BluetoothManagerService.java:1083)
at com.android.server.bluetooth.BluetoothManagerService.enable(BluetoothManagerService.java:1278)
at android.bluetooth.IBluetoothManager$Stub.onTransact(IBluetoothManager.java:177)
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.BLUETOOTH_ADVERTISE)
AddPermission(android.permission.BLUETOOTH_CONNECT)
AddPermission(android.permission.BLUETOOTH_SCAN)
AddPermission(android.permission.WAKE_LOCK)
Sub btnSearchForDevices_Click rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION) Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) If Result = False And rp.Check(rp.PERMISSION_ACCESS_COARSE_LOCATION) = False Then ToastMessageShow("No permission...", False) Return End If If phone.SdkVersion >= 31 Then For Each Permission As String In Array("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT") rp.CheckAndRequest(Permission) Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) If Result = False Then ToastMessageShow("No permission...", False) Return End If Next End If Dim success As Boolean = admin.StartDiscovery If success = False Then ToastMessageShow("Error starting discovery process.", True) Else SelectPairing.Clear Dim Index As Int = ShowProgress Wait For Admin_DiscoveryFinished HideProgress(Index) If SelectPairing.Size = 0 Then ToastMessageShow("No device found.", True) End If End If End Sub:
Sub btnSearchForDevices_Click
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result = False And rp.Check(rp.PERMISSION_ACCESS_COARSE_LOCATION) = False Then
ToastMessageShow("No permission...", False)
Return
End If
If phone.SdkVersion >= 31 Then
For Each Permission As String In Array("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT")
rp.CheckAndRequest(Permission)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("No permission...", False)
Return
End If
Next
End If
Dim success As Boolean = admin.StartDiscovery
If success = False Then
ToastMessageShow("Error starting discovery process.", True)
Else
SelectPairing.Clear
Dim Index As Int = ShowProgress
Wait For Admin_DiscoveryFinished
HideProgress(Index)
If SelectPairing.Size = 0 Then
ToastMessageShow("No device found.", True)
End If
End If
End Sub
Last edited: