Urovo Printer SDK (urovoPrinterLib) is a thermal printing library for UROVO POS devices with built-in printers. It supports text, barcodes, QR codes, images, HTML, and label printing. The main entry class is com.urovo.sdk.print.PrinterProviderImpl.
Item
Detail
Version
1.0.6
Platform
Android
Min SDK
API 21 (Android 5.0)
Target SDK
API 33
Max paper width
384 dots (~58 mm thermal paper)
1.2、Version history
This document corresponds to SDK release 1.0.6 (urovoPrinterLib_v1.0.6_release.aar).
Recommended lifecycle: getInstance → initPrint → add content → startPrint → close. Call close() after each print job and initPrint() before the next. Check getStatus() before printing.
Authentication: None (built-in printer, no API keys).
Initializes the printer before each new print job.
public int initPrint()
Returns
int — 0 (PrintStatus.ERROR_NONE) on success; see PrintStatus for other values.
com.urovo.sdk.print.PrinterProviderImpl
4.1.3、getStatus
Returns the current printer status.
public int getStatus()
Returns
int — status code; see PrintStatus.
Errors
Code
Meaning
Handling
0x00
OK / success
Proceed with printing
0xF0
Out of paper
Reload paper and retry
0xF3
Overheat
Wait for cooldown
0xE1
Low voltage
Check power/battery
0xF7
Printer busy
Retry later
0xF2
Hardware error
Inspect device
0xFB
Printer error
Inspect device
Other
Print failed
Map via PrintStatus
com.urovo.sdk.print.PrinterProviderImpl
4.1.4、setGray
Sets print density / grayscale.
public void setGray(int gray)
Parameters
Name
Type
Description
gray
int
Grayscale level, range -6 to 6
com.urovo.sdk.print.PrinterProviderImpl
4.1.5、setSpeed
Sets print speed.
public int setSpeed(int speedLevel)
Parameters
Name
Type
Description
speedLevel
int
Speed level, range 10–20
Returns
int — 0 on success; other values on failure.
com.urovo.sdk.print.PrinterProviderImpl
4.1.6、addText
Adds one line of text with the given format.
public void addText(Bundle format, String text)
Parameters
Name
Type
Description
format
Bundle
Keys from PrintFormat: FONT (0 small / 1 normal / 2 large, default 1), FONTBOLD (default false), ALIGN (0 left / 1 center / 2 right), FONTNAME (TTF path), FONTSIZE (overrides FONT when set), LINEHEIGHT
text
String
Text to print
com.urovo.sdk.print.PrinterProviderImpl
4.1.7、addTextLeft_Right
Prints left and right columns on one line (Bundle overload; recommended).
public void addTextLeft_Right(Bundle format, String textLeft, String textRight)
Parameters
Name
Type
Description
format
Bundle
Font/alignment keys same as addText
textLeft
String
Left text
textRight
String
Right text
com.urovo.sdk.print.PrinterProviderImpl
4.1.8、addTextLeft_Center_Right
Prints left, center, and right columns on one line.
public void addTextLeft_Center_Right(Bundle format, String textLeft, String textCenter, String textRight)
Parameters
Name
Type
Description
format
Bundle
Font/alignment keys same as addText
textLeft
String
Left column
textCenter
String
Center column
textRight
String
Right column
com.urovo.sdk.print.PrinterProviderImpl
4.1.9、feedLine
Feeds paper by the given number of lines.
public void feedLine(int lines)
Parameters
Name
Type
Description
lines
int
Line count; 0 adds bottom margin; -1 no margin (feed to cutter if supported)
com.urovo.sdk.print.PrinterProviderImpl
4.1.10、addBlankLine
Adds blank space with the given height.
public void addBlankLine(int height)
Parameters
Name
Type
Description
height
int
Blank height
com.urovo.sdk.print.PrinterProviderImpl
4.1.11、addBlackLine
Adds a black separator line.
public void addBlackLine(int... lineHeight)
Parameters
Name
Type
Description
lineHeight
int...
Variable line heights
com.urovo.sdk.print.PrinterProviderImpl
4.1.12、addBarCode
Adds a 1D barcode.
public void addBarCode(Bundle format, String barcode)
Parameters
Name
Type
Description
format
Bundle
align (0 left / 1 center / 2 right), width, height, PrintFormat.BARCODE_TYPE
barcode
String
Barcode payload
com.urovo.sdk.print.PrinterProviderImpl
4.1.13、addQrCode
Adds a QR code.
public void addQrCode(Bundle format, String qrCode)
Parameters
Name
Type
Description
format
Bundle
align (when offset=-1), offset, expectedHeight
qrCode
String
QR payload
com.urovo.sdk.print.PrinterProviderImpl
4.1.14、addImage
Adds a bitmap from a byte array. Max printable width ~384 dots; width should be ≤ 380.
public void addImage(Bundle format, byte[] imageData)
Use PrintStatus.getPrinterStatusDes(context, code) for localized descriptions.
4.4、PrinterLabelState
com.urovo.sdk.print.PrinterLabelState
Value
Meaning
PRN_LABEL_STUDY (0x00)
Learn label height (not available)
PRN_LABEL_LOCATION (0x01)
Label positioning (before each job)
PRN_LABEL_CONTINUE (0x02)
Continuous label feed
PRN_LABEL_END (0x03)
End label job feed
5、Examples
Samples from Demo MainActivity.java (com.urovo.print.test). Run printing on a background thread.
5.1、Query printer status
java
PrinterProviderImpl mPrintManager = PrinterProviderImpl.getInstance(context);
mPrintManager.initPrint();
int status = mPrintManager.getStatus();
// status == 0 means printer is ready
mPrintManager.close();
Notes: Call initPrint() before query and close() when done; check getStatus() before printing.
5.2、Full receipt print
java
PrinterProviderImpl mPrintManager = PrinterProviderImpl.getInstance(context);
new Thread(() -> {
try {
mPrintManager.initPrint();
if (mPrintManager.getStatus() != 0) return;
mPrintManager.setGray(0);
mPrintManager.setSpeed(15);
Bundle format = new Bundle();
byte[] imageData = getBitmapBytes(bitmap);
format.putInt(PrintFormat.ALIGN, PrintFormat.ALIGN_CENTER);
format.putInt(PrintFormat.WIDTH, 196);
format.putInt(PrintFormat.HEIGHT, 58);
mPrintManager.addImage(format, imageData);
format = new Bundle();
format.putInt(PrintFormat.FONT, PrintFormat.FONT_NORMAL);
format.putInt(PrintFormat.ALIGN, PrintFormat.ALIGN_CENTER);
format.putBoolean(PrintFormat.FONTBOLD, true);
mPrintManager.addText(format, "CENTER");
format = new Bundle();
format.putInt(PrintFormat.FONT, PrintFormat.FONT_NORMAL);
mPrintManager.addTextLeft_Right(format, "Item", "$15");
mPrintManager.addTextLeft_Center_Right(format, "Item", "16", "$15");
format = new Bundle();
format.putInt(PrintFormat.ALIGN, PrintFormat.ALIGN_CENTER);
format.putInt(PrintFormat.WIDTH, 300);
format.putInt(PrintFormat.HEIGHT, 100);
mPrintManager.addBarCode(format, "33333333333333");
mPrintManager.feedLine(3);
format = new Bundle();
format.putInt(PrintFormat.ALIGN, PrintFormat.ALIGN_CENTER);
format.putInt(PrintFormat.EXHEIGHT, 100);
mPrintManager.addQrCode(format, "222222222222222222222");
mPrintManager.feedLine(-1);
int iRet = mPrintManager.startPrint();
mPrintManager.close();
} catch (Exception e) {
e.printStackTrace();
}
}).start();
Notes:startPrint() blocks; use a worker thread; keep image width ≤ 380.
5.3、HTML print
java
mPrintManager.initPrint();
if (mPrintManager.getStatus() != 0) return;
mPrintManager.setGray(6);
String content = htmlConvertToString(context, "html_text_document.txt");
Bundle format = new Bundle();
format.putInt(PrintFormat.ALIGN, PrintFormat.ALIGN_CENTER);
format.putInt(PrintFormat.WIDTH, 380);
mPrintManager.addHtml(format, content);
mPrintManager.startPrint();
mPrintManager.close();
5.4、Label print
java
mPrintManager.initPrint();
if (mPrintManager.getStatus() != 0) return;
if (!mPrintManager.supportLabelPrint()) return;
if (!mPrintManager.setPrinterMode(true)) return;
mPrintManager.setLabelFeed(PrinterLabelState.PRN_LABEL_LOCATION);
mPrintManager.addBlankLine(topMargin);
byte[] imageData = getBitmapBytes(labelBitmap);
Bundle format = new Bundle();
format.putInt(PrintFormat.WIDTH, labelBitmap.getWidth());
format.putInt(PrintFormat.HEIGHT, labelBitmap.getHeight());
mPrintManager.addImage(format, imageData);
mPrintManager.feedLine(-1);
mPrintManager.startPrint();
mPrintManager.setLabelFeed(PrinterLabelState.PRN_LABEL_END);
mPrintManager.close();
Notes: Check supportLabelPrint() first; call setLabelFeed(PRN_LABEL_LOCATION) before content; call PRN_LABEL_END after print.
6、Notes & FAQ
6.1、Notes
Lifecycle: Call close() after each job; call initPrint() before the next to avoid resource leaks.
Threading:startPrint() is synchronous; avoid long prints on the main thread.
Paper width: Do not exceed 384 dots; image width ≤ 380 recommended.
Fonts: Custom TTF paths must be readable; grant storage permissions.
PrinterProviderImpl mPrintManager = PrinterProviderImpl.getInstance(context);
mPrintManager.initPrint();
int status = mPrintManager.getStatus();
// status == 0 表示打印机正常
mPrintManager.close();