Android Question Problem to print on integrated mobile printer

Julio Montilla

Member
Licensed User
I have trouble printing with an integrated mobile point of sale printer. I have attached the image of the printer.

My code works well with bluetooth printer but with the integrated printer does not work.

My code is as follows

B4X:
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
    OSerial.Initialize("OSerial")
    PairedDevices = OSerial.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
 

Attachments

  • Sin título.jpg
    Sin título.jpg
    35.7 KB · Views: 525

DonManfred

Expert
Licensed User
Longtime User
My code works well with bluetooth printer but with the integrated printer does not work.
Maybe you need to use their SDK? Is there any example project and/or SDK Available for this device?
What Manufacturer and what model exactly it is?
 
Upvote 0

Everett L Duty Sr.

New Member
Licensed User
I have trouble printing with an integrated mobile point of sale printer. I have attached the image of the printer.

My code works well with bluetooth printer but with the integrated printer does not work.

My code is as follows

B4X:
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
    OSerial.Initialize("OSerial")
    PairedDevices = OSerial.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
 
Upvote 0

Everett L Duty Sr.

New Member
Licensed User
did anyone ever solve this problem of printing to an integrated printer?
I have same device but Android 6.
Built in POS steward prints perfect. including barcode etc.
Loyverse POS software works also but I need some help with my own B4A app to print to it.
Any suggestions would be greatly appreciated including what libraries and how to install them.
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
did anyone ever solve this problem of printing to an integrated printer?
I have same device but Android 6.
Built in POS steward prints perfect. including barcode etc.
Loyverse POS software works also but I need some help with my own B4A app to print to it.
Any suggestions would be greatly appreciated including what libraries and how to install them.

B4X:
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

On my Sunmi V1 print is ok, correct Oserial to LocalOSerial
buildin printer name is InnerPrinter, must be connected as Bluetooth device



IMG_20191222_112717.jpg
 
Last edited:
Upvote 0

Everett L Duty Sr.

New Member
Licensed User
Thank you so much! I needed to find my printers name. It contained "Printer" so that fixed the problem
also I forgot to attach the serial library. Been programming a long time but new to Android and B4A.
 
Upvote 0
Top