Android Question Bluetooth BLE on Android 14 does not work for me

cutstone

Member
Licensed User
Longtime User
I have Bluetooth scan and connection working great before upgrading Samsung Tablet to Android 14. Now it is stuck, like I need to open for something, so what am I missing?
This program runs fine on a Android 12 device, showing devices around me. Same program show nothing on Android 14.


BT Scanner:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private manager As BleManager2
End Sub

Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Permissions
    Dim PM As PermissionsManager
    
    PM.CheckAndRequestPermission(PermissionsManager.DANGEROUS_BLUETOOTH_SCAN)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        Log("BLUETOOTH_SCAN NOT Grantet")
    End If
        
    PM.CheckAndRequestPermission(PermissionsManager.DANGEROUS_BLUETOOTH_CONNECT)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        Log("ACCESS_BLUETOOTH_CONNECT NOT Grantet")
    End If

    PM.CheckAndRequestPermission(PermissionsManager.DANGEROUS_ACCESS_FINE_LOCATION)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        Log("ACCESS_FINE_LOCATION NOT Grantet")
    End If

End Sub

Private Sub Button1_Click
    Permissions
    
    manager.Initialize("manager")
    If manager.State <> manager.STATE_POWERED_ON Then
        Log("Error starting discovery process. Is bluetooth active")
    Else
        Log("Start discovery")
        manager.Scan(Null)
    End If
End Sub

Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
    Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData)
End Sub


Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<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_SCAN)
AddPermission(android.permission.BLUETOOTH_CONNECT)


Compiling information:
B4A Version: 13.00
Parsing code.    (0.01s)
    Java Version: 19
Building folders structure.    (0.02s)
Running custom action.    (0.06s)
Compiling code.    (0.10s)
Compiling layouts code.    (0.02s)
Organizing libraries.    (0.02s)
    (AndroidX SDK)
Compiling resources    (0.08s)
Linking resources    (0.18s)
    build tools: 34.0.0, android jar: android-34

I even tried the Bluetooth Chat example postet in this forum. Same thing, works on Android 12, but not 14.
 
Top