Hi
I have the following code:
I would like to have below steps in my application:
- after first starting application all available devices should be searched,
- next one of them should be chosen by user and connection should be established
- after resuming the application from pause/sleep mode the connection should be established with the last choose device (In pause/sleep mode the connection will be disconnected)
Currently before finishing searching devices the list is showed ( the application does not wait for discoveryfinished I need something like while) and I do not know how to resume the connection.
Regards
Artur
I have the following code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
If FirstTime = True Then
admin.Initialize("admin")
serial1.Initialize("Serial1")
search_devices
End If
End Sub
B4X:
Sub Activity_Resume
If admin.IsEnabled = False Then
If admin.Enable = False Then
ToastMessageShow(" BT ERROR,True)
Else
ToastMessageShow(" BT ON",True)
connect_device
End If
Else
End If
End Sub
B4X:
Sub search_devices
foundDEvices.Initialize
If admin.StartDiscovery = False Then
ToastMessageShow("ERRROR",True)
Else
ProgressDialogShow("SEARCHING.")
End If
End Sub
B4X:
Sub connect_device
Dim pairedDevice As Map
pairedDevice = serial1.GetPairedDevices
Dim IL As List
IL.Initialize
For i=0 To pairedDevice.Size-1
IL.Add(pairedDevice.GetKeyAt( i ))
Next
Dim res As Int
res = InputList(IL," BT devices :",-1)
If res <> DialogResponse.CANCEL Then
serial1.Connect(pairedDevice.Get (IL.Get ( res)))
End If
End Sub
I would like to have below steps in my application:
- after first starting application all available devices should be searched,
- next one of them should be chosen by user and connection should be established
- after resuming the application from pause/sleep mode the connection should be established with the last choose device (In pause/sleep mode the connection will be disconnected)
Currently before finishing searching devices the list is showed ( the application does not wait for discoveryfinished I need something like while) and I do not know how to resume the connection.
Regards
Artur