我开发了带有颤动的移动销售点,但是我不知道如何在蓝牙热敏打印机上打印收据
我目前为此开发了一个插件,但目前还无法正常工作
protected void printBill() {
if(btsocket == null){
btsocket = DeviceList.getSocket();
Intent BTIntent = new Intent(getApplicationContext(), DeviceList.class);
this.startActivityForResult(BTIntent, DeviceList.REQUEST_CONNECT_BT);
Toast.makeText(activity,"tes",Toast.LENGTH_LONG).show();
}
else{
OutputStream opstream = null;
try {
opstream = btsocket.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
outputStream = opstream;
//print command
try {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
outputStream = btsocket.getOutputStream();
byte[] printformat = new byte[]{0x1B,0x21,0x03};
outputStream.write(printformat);
printCustom("Fair Group BD",2,1);
printCustom("Pepperoni Foods Ltd.",0,1);
printCustom("H-123, R-123, Dhanmondi, Dhaka-1212",0,1);
printCustom("Hot Line: +88000 000000",0,1);
printCustom("Vat Reg : 0000000000,Mushak : 11",0,1);
String dateTime[] = getDateTime();
printText(leftRightAlign(dateTime[0], dateTime[1]));
printText(leftRightAlign("Qty: Name" , "Price "));
printCustom(new String(new char[32]).replace("\0", "."),0,1);
printText(leftRightAlign("Total" , "2,0000/="));
printNewLine();
printCustom("Thank you for coming & we look",0,1);
printCustom("forward to serve you again",0,1);
printNewLine();
printNewLine();
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
可以找到源代码here
请帮助我开发此插件,至少它可以打印文本