Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
DirectPrint("InnerPrinter","Prova di stampa")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
public Sub DirectPrint(aPrinter As String, aData As String)
Dim PairedDevices As Map
Dim LocalBTMac As String
Dim LocalOSerial As Serial
Dim LocalPrinter As TextWriter
LocalOSerial.Initialize("OSerial")
PairedDevices = LocalOSerial.GetPairedDevices
For i = 0 To PairedDevices.Size - 1
Dim device As String = PairedDevices.GetKeyAt(i)
If device.Contains(aPrinter) Then
LocalBTMac = PairedDevices.get(device)
LocalOSerial.Initialize("DirectPrint")
LocalOSerial.Connect(LocalBTMac)
Wait For DirectPrint_Connected (Success As Boolean)
If Success Then
' LocalPrinter.Initialize(LocalOSerial.OutputStream)
LocalPrinter.Initialize2(LocalOSerial.OutputStream,"windows-1252") 'important
LocalPrinter.WriteLine(aData)
LocalPrinter.Flush
LocalPrinter.Close
LocalOSerial.Disconnect
End If
End If
Next
End Sub