#Region Project Attributes
#ApplicationLabel: Test
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
#AdditionalJar: com.android.support:support-v4
Sub Process_Globals
'Public Manager As BluetoothManager
Private rp As RuntimePermissions
Dim loc As AHLocale
End Sub
Sub Globals
Private btnSearchForDevices As Button
Private btnexit As Button
Private sonLang As Spinner
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
'UpdateState
End Sub
Public Sub UpdateState
If Starter.Manager.BluetoothState=True Then
'UpdateState
rp.CheckAndRequest(rp.PERMISSION_ACCESS_COARSE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("Нет разрешения...", False)
Return
End If
Dim success As Boolean = Starter.Manager.SearchForDevices
If success = False Then
ToastMessageShow("Ошибка запуска процесса поиска.", True)
Else
ProgressDialogShow2("Поиск утройств...", False)
End If
End If
'btnSearchForDevices.Enabled = Starter.Manager.BluetoothState
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnSearchForDevices_Click
StartService(Starter)
UpdateState
End Sub
Public Sub DiscoverFinished
ProgressDialogHide
If Starter.Manager.foundDevices.Size = 0 Then
ToastMessageShow("Устройства не найдены.", True)
Else
Dim l As List
l.Initialize
For Each nm As NameAndMac In Starter.Manager.foundDevices
l.Add(nm.Name)
Next
InputListAsync(l, "Выберете устройство для подключения:", -1, True)
Wait For InputList_Result (Index As Int)
If Index <> DialogResponse.CANCEL Then
Dim device As NameAndMac = Starter.Manager.foundDevices.Get(Index)
Starter.Manager.ConnectTo(device)
ProgressDialogShow2($"Попытка подключиться к: ${device.Name} (${device.Mac})"$, False)
End If
End If
End Sub
Public Sub AfterConnect (Success As Boolean)
ProgressDialogHide
End Sub