Hi, I'm new here, and have very little experience with B4A.
Few years back I wrote simple application to connect to Bluetooth serial device(SPP).
Now I need similar thing, so I buy new version of B4A, used same code and have mixed results.
On galaxy s1 and s3 I see device in list, on S2, S6 and S7 returned list is always empty.
I tried to run with debugger, I run same .apk on every phone, and results are same.
S1 and S3 works, other doesn't.
When I install old .apk file I can connect on every device.
Here is code that I used to connect to Bluetooth.
Java:
C:\Program Files\Java\jdk1.8.0_172\bin\javac.exe
Android SDK:
D:\Android\android-sdk\platforms\android-25\android.jar
Did I leave any important details?
Do I need to add some permission or something like that?
Any other idea?
Thanks
Few years back I wrote simple application to connect to Bluetooth serial device(SPP).
Now I need similar thing, so I buy new version of B4A, used same code and have mixed results.
On galaxy s1 and s3 I see device in list, on S2, S6 and S7 returned list is always empty.
I tried to run with debugger, I run same .apk on every phone, and results are same.
S1 and S3 works, other doesn't.
When I install old .apk file I can connect on every device.
Here is code that I used to connect to Bluetooth.
B4X:
Sub BTAdmin_DeviceFound (Name As String, MacAddress As String) 'Newer rises on s2 s6 s7
log(Name & ":" & MacAddress)
Dim nm As NameAndMac
nm.Name = Name
nm.Mac = MacAddress
foundDevices.Add(nm)
ProgressDialogShow("Searching for devices (~ device found)...".Replace("~", foundDevices.Size))
End Sub
Sub BTAdmin_DiscoveryFinished
ProgressDialogHide
Dim l As List
l.Initialize
For i = 0 To foundDevices.Size - 1
Dim nm As NameAndMac
nm = foundDevices.Get(i)
l.Add(nm.Name)
Next
l.Add("Search nearby devices")
Dim res As Int
res = InputList(l, "Choose device to connect", -1)
If res <> DialogResponse.CANCEL Then
If res<l.Size-1 Then
connectedDevice = foundDevices.Get(res)
ProgressDialogShow("Trying to connect to: " & connectedDevice.Name)
serial1.Connect(connectedDevice.Mac)
Connected=True
Else
foundDevices.Initialize
If BTAdmin.StartDiscovery = False Then
ToastMessageShow("Error starting discovery process.", True)
tbStatus.Checked=False
Else
ProgressDialogShow("Searching for devices...")
End If
End If
Else
tbStatus.Checked=False
End If
C:\Program Files\Java\jdk1.8.0_172\bin\javac.exe
Android SDK:
D:\Android\android-sdk\platforms\android-25\android.jar
Did I leave any important details?
Do I need to add some permission or something like that?
Any other idea?
Thanks