Android Development (42) using Andorid to operate a Bluetooth printer

Source: Internet
Author: User

Recently received a request to use Android to initiate a print task, connect the printer via Bluetooth. The conditions are as follows:

Printer: Nanjing Fujitsu dpk760e, with Bluetooth function

Android Phone: normal phone, Android 4.4 version, with Bluetooth function

Specific operation:

1. Bluetooth handshake

2. Establishing a communication connection

3. Send Print Instructions

-------------------

Use the official provided examples can support the 1th, 2 steps, the difficulty is the third step. The official provided example does not manipulate the location coordinates of the print, after repeated functions, the following commands are obtained:

A. Roll paper, move the paper operation, equivalent to the Y axis, but this is a relative position, that is, the hair once moved 1 cm, and, can not be reversed.

B. Horizontal movement of the print coordinates, absolute position, equivalent to moving the x axis

C. Print output text

D. end of printing.

-------------------

Because the y-axis is a relative coordinate, coding can be cumbersome. I think of a way to create a location description (template) of all the content that needs to be printed, put it in a collection, sort it, sort it in ascending order of y size, and then sort by x in ascending order. When you are finished, define a y_cursor record to hold the current absolute position coordinates.

Demo download

Android Development (42) using Andorid to operate a Bluetooth printer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.