Android Question Can I print to thermal printers with my phone locked?

Waldemar Lima

Well-Known Member
Licensed User
Hello guys, I have an impeccable ... I need to print information received by an application while the phone is connected to the thermal printer's bluetooth at the same time that it is locked or with the application closed to print via bluetooth using "Service".

in short>: I need to print on a thermal printer on android, in the background (cell phone blocked or with the application minimized or closed), is this possible?
 

Peter Simpson

Expert
Licensed User
Longtime User
in short>: I need to print on a thermal printer on android, in the background (cell phone blocked or with the application minimized or closed), is this possible?
I presume that you would be able to achieve this if you use PartialLock in PhoneWakeState of the phone library.

Think about it like a background music player. It's just a background task that is using AsyncStreams and Serial. The serial library can be used to scan for previously connected Bluetooth devices using GetPairedDevices.

Sending a line of data to the BT Printed is done something like this if your printer uses the Standard Epson ESC/POS commands (which most EPOS equipment do).
B4X:
'One line
    Dim Msg As String = $"Developed in ß4Ä${CRLF}Using Serial Lib" ${CRLF}"$
    BTDevice.Write(Msg.GetBytes("ISO-8859-1"))

Please note, I've not tried this but it should not be too difficult a task to complete...
 
Last edited:
Upvote 0
Top