Hello
I learn from the example https://www.b4x.com/android/forum/threads/b4x-ble-2-bluetooth-low-energy.59937/#content of by Erel.
The task I set myself was to skip using the "btnScan" button, so that the application automatically searched for a specific device and automatically connected to it.
Seems simple, but ....
If I put the function call "btnScan_Click" somewhere in another function, the program lines following the expression:
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
are no longer performed and the program does not start scanning ("StartScan" function)
The program, after line "Wait For...." jumps to the function "Activity_PermissionResult" (in Main module code), then calls the function B4XPage_Appear (in the moduleB4XMainPage) and ends there.
I don't understand why this is happening.
An extra line in the manifest is added:
AddPermission (android.permission.ACCESS_FINE_LOCATION)
Appropriate permissions are set on the smartphone.
I learn from the example https://www.b4x.com/android/forum/threads/b4x-ble-2-bluetooth-low-energy.59937/#content of by Erel.
The task I set myself was to skip using the "btnScan" button, so that the application automatically searched for a specific device and automatically connected to it.
Seems simple, but ....
If I put the function call "btnScan_Click" somewhere in another function, the program lines following the expression:
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
are no longer performed and the program does not start scanning ("StartScan" function)
The program, after line "Wait For...." jumps to the function "Activity_PermissionResult" (in Main module code), then calls the function B4XPage_Appear (in the moduleB4XMainPage) and ends there.
I don't understand why this is happening.
An extra line in the manifest is added:
AddPermission (android.permission.ACCESS_FINE_LOCATION)
Appropriate permissions are set on the smartphone.
B4X:
Sub btnScan_Click
#if B4A
'Don't forget to add permission to manifest
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
'================== break in the run. ===== The next lines are skipped.=======
If Result = False Then
ToastMessageShow("No permission", True)
Return
End If
#end if
pbScan.Show
StartScan 'this line dont work
End Sub