Sub cmdDiscover_click
'this intent makes the device discoverable For 300 seconds.
Dim i As Intent
i.Initialize("android.bluetooth.adapter.action.REQUEST_DISCOVERABLE", "")
i.PutExtra("android.bluetooth.adapter.extra.DISCOVERABLE_DURATION", 300)
StartActivity(i)
Remote1.Listen
Remote2.Listen
End Sub
'=========================================================================================
'REMOTE CONTROL SUBROUTINES
'=========================================================================================
Sub Remote1_Connected (Success As Boolean)
Log("Remote 1 connected: " & Success)
If Success = True Then
If AstreamRemote.IsInitialized = False Then
AstreamRemote.InitializePrefix(Remote1.InputStream, True, Remote1.OutputStream, "AStreamRemote")
End If
Else
Log("Connection Broke")
End If
End Sub
Sub Remote2_Connected (Success As Boolean)
Log("Remote 2 connected: " & Success)
If Success = True Then
If AstreamRemote2.IsInitialized = False Then
AstreamRemote2.InitializePrefix(Remote2.InputStream, True, Remote2.OutputStream, "AStreamRemote2")
End If
Else
Log("Connection Broke")
End If
End Sub
Sub AStreamRemote_NewData (Buffer() As Byte)
Log("Remote 1: " & BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub
Sub AStreamRemote_Error
ToastMessageShow("Remote 1 has Disconnected.", True)
AstreamRemote.Close
Remote1.Disconnect
End Sub
Sub AStreamRemote_Terminated
AStreamRemote_Error
End Sub
Sub AStreamRemote2_NewData (Buffer() As Byte)
Log("Remote 2: " & BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub
Sub AStreamRemote2_Error
ToastMessageShow("Remote 2 has Disconnected.", True)
AstreamRemote2.Close
Remote2.Disconnect
End Sub
Sub AStreamRemote2_Terminated
AStreamRemote2_Error
End Sub