Advanced Android – Android calls ESC / POS printer to print an instance
preface
Some time ago, due to work needs, we need to study the Android program calling the printer to print small tickets, and it is required that Bluetooth calling cannot be used. After research, we can use socket connection to realize the printing function. Wrote a demo and shared it.
Tools: a printer (Xinye xp-80xx) and an Android tester
Development environment: Android studio 1.5
Requirements: click the button to realize the function of printing small ticket. In addition to the necessary text, there should also be two-dimensional code on the small ticket.
Encapsulates a POS printing tool class:
The printer's IP and port number can be found from the printer's attribute settings.
Calling from mainactivity:
Attachment: bean class of dishes in small ticket
Print the small ticket sample as shown in the figure:
Summary:
For calling the printer, whether using java language or other languages, the idea is the same. After connecting the printer with socket, output and print through IO stream. Their printing instructions are the same. You can download the printing manual and use different printing instructions for different settings.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.