AmLimit
New Member
Hi,
a few years ago I wrote an application for a tablet with an old Android Version (9 or so - it crashed). It receives data from an HC-05 and shows them on the tablet screen.
Now I try to get it running again on an Android 15 tablet but I fail. On debugging the line containing ".GetPairedDevices" (line 11) is shown as problem with:
java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@5d3e6901: AdapterService getBondedDevices
I had a look into several treads here but was not able to find my solution. Meanwhile I added some lines (15..19) to the manifest:
But this didn't solve my issue.
There are not any permissions on the downloaded app if I look into the App-Info on my tablet.
What is missing to get Bluetooth running for this app?
a few years ago I wrote an application for a tablet with an old Android Version (9 or so - it crashed). It receives data from an HC-05 and shows them on the tablet screen.
Now I try to get it running again on an Android 15 tablet but I fail. On debugging the line containing ".GetPairedDevices" (line 11) is shown as problem with:
java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@5d3e6901: AdapterService getBondedDevices
Main:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
'initialize serial interface for Bluetooth communication
serialBt.Initialize("BTinterface")
'check if initialization went good
If serialBt.IsEnabled Then
'read in all paired devices
Dim pairedDevices As Map
pairedDevices = serialBt.GetPairedDevices
'search for device named "EasyFlap" and connect if found
For i=0 To pairedDevices.Size - 1
Log(pairedDevices.GetKeyAt(i))
Log(pairedDevices.GetValueAt(i))
If pairedDevices.GetKeyAt(i) == "EasyFlap" Then
serialBt.Connect(pairedDevices.GetValueAt(i))
Log("------------------------------------> found")
'initialize measurement request timer
measRequestTimer.Initialize("ReadTimer", 100)
End If
Next
Else
Log("serial init fail")
End If
.
.
.
.
End Sub
I had a look into several treads here but was not able to find my solution. Meanwhile I added some lines (15..19) to the manifest:
Manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35"/>
<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.
'added
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.BLUETOOTH_ADVERTISE)
AddPermission(android.permission.BLUETOOTH_CONNECT)
AddPermission(android.permission.BLUETOOTH_SCAN)
But this didn't solve my issue.
There are not any permissions on the downloaded app if I look into the App-Info on my tablet.
What is missing to get Bluetooth running for this app?