Sub Activity_Create(FirstTime As Boolean)
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
....
end sub
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
Select Case Permission
Case rp.PERMISSION_WRITE_EXTERNAL_STORAGE
If Result Then
ToastMessageShow("Permission OK",True)
End If
Case rp.PERMISSION_ACCESS_FINE_LOCATION
If Result Then
ToastMessageShow("BT Permission OK",True)
End If
End Select
End Sub
It produces a curious effect ONLY running in a device with Android 7 (and 8 I suppose)
After scanning, the Manager_DeviceFound is fired correctly
B4X:
Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
If Id=Starter.StoredId then
manager.Connect2(Id,False)
end if
end sub
But Immediately after Connect2 (and Connect also), the event fired is Manager_Disconnected
(instead of Manager_Connected)
If I run the app in a phone with Android 4 or 5, all is working perfect.
And I don’t know how to manage this. Any idea?
I’m using B4A 8.0 and BLE2 V 1.36
Thanks for the idea, but it does not work. Same problem.
The behavior of the example and my app is the same (after putting sdk = 26)
I tried with three different devices and always the same. Scan is correct, but when I call manager.Scan2(Null, False) , the event fired is Manager_Disconnected
This is with a BM77 (a Microchip device)
B4X:
Logger connected to: samsung SM-J530F
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Class not found: b4a.example.customlistview, trying: b4a.example3.customlistview
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (main) Resume **
Found: Test 1 , 34:81:F4:14:B1:D9, RSSI = -59, (MyMap) {1=[B@367ab89, 9=[B@e5df78e, 0=[B@543dbaf}
Disconnected
Found: Test 1 , 34:81:F4:14:B1:D9, RSSI = -64, (MyMap) {1=[B@1fc83cb, 9=[B@2ae27a8, 0=[B@82c42c1}
Disconnected
Testing more than thirty times, ONE connection has been successful.
I tried to delay the connection one or two seconds, in case this was the problem, but there is no variation.
Trying SDK=21 and lower, the problem persist.
The phone is a Samsung J5 2017 with Android 7.
With a Samsung S4 Android 4.4.2 works perfect