Android-SDK3.0 Development Document
Android-SDK3.0 Development Document
V3.0
一、 Introduction
The SDK contains Bluetooth, Usb and WiFi.
1. Software package name:com.android.print.sdk
2. Classes name:
1. Construct method:
a) //use BluetoothDevice
PrinterInstance(Context context, BluetoothDevice bluetoothDevice, Handler
handler)
b) //use UsbDevice
Handler: use for receive connect state change. Use constant value:
PrinterConstants.Connect.SUCCESS;
PrinterConstants.Connect.FAILED;
PrinterConstants.Connect.CLOSED;
a) Init printer.
init()
printText(String content)
sendByteData(byte[] content)\
user can use this method send command to printer if the SDK don’t provide the
command[0] = 0x1B;
command[1] = 0x31;
command[2] = 49;
sendByteData (command);
d) Print image.
zoom in.
printImage(Bitmap bitmap);
printTable(Table table)
PrintBarCode(Barcode barcode)
g) Cut pager
cutPaper()
ringBuzzer(byte time)
i) Open cashbox
openCashbox(boolean cashbox1, boolean cashbox2)
4. Set method:
setEncoding(String encoding)
setCharacterMultiple(int x, int y)
isBold:bold
isDoubleHeight:double height.
isDoubleWidth:double width.
isUnderLine:under line.
setPrinter(int command)
WAKE_PRINTER:wake up printer
PRINT_AND_WAKE_PAPER_BY_LNCH:
三、 Table class
1. Table construct.
as”,”.
addRow(String row)
Add a row data to the table. Data form should equals with table
title. If the table cell width exceeds the limit, printer can word
wrap, if want manual line, can add “\n” in where you want.
setColumnAlignLeft(boolean left)
四、 Barcode class
1. Construct:
Barcode(byte barcodeType)
Barcode(byte barcodeType, int param1, int param2, int param3, String content)
Two-dimensional: PDF417,DATAMATRIX,QRCODE。
a) PDF417
param3:Longitudinal magnification。
b) DATA MATRIX
param1:height,0<=n<=144(0:auto select)。
param3:Longitudinal magnification。
c) QR CODE
n = 76,77,81,72(L:7%,M:15%,Q:25%,H:30%)。
param3:Longitudinal magnification。
1. Init CanvasPrint, Parameter is PrinterType. If use this method. The canvas was init
init(PrinterType printerType)
setFontProperty(FontProperty fp)
If don’t use this method, you also can use the following method:
drawText(String nStr)
4. Draw a line. Parameters startX, startY is start coordinate; stopX , stopY is end
coordinate.
5. Draw a rectangle. Parameters are the distance of edge to the left and top.
ellipse.
drawImage(Bitmap image);
drawImage(float left, Bitmap image);
getCanvasImage();
9. Set text aligns right. Against the special language. Such as Arabic.
setTextAlignRight(boolean alignRight);
10. Set print new line if the text exceeds the valid width.
setTextExceedNewLine(boolean newLine);
setUseSplit(boolean useSplit);