I was download epson android sdk from https://download.epson-biz.com/modules/pos/index.php?page=single_soft&cid=5228&pcat=7&pid=4179. I have an Epson TM-T81 series printer,When i try to connect this sdk with my printer it show Error code(ERR_UNSUPPORTED),but when i change the printer series to TM-T82 or some other from the spinner, it works fine with my TM-T81 printer but it is not working when i select TM-T81.What is the reason for that?
1 Answers
0
votes
You can use like this. This answer Will Help you.
public boolean initializeObject(Printer printerSeries) {
try {
// mPrinter=new Printer(Printer.TM_T88,Printer.LANG_EN,mContext);
or
mPrinter=new Printer(printerSeries,Printer.LANG_EN,mContext);
}
catch (Exception e) {
ShowMsg.showException(e, "Printer", mContext);
return false;
}
mPrinter.setReceiveEventListener(new com.epson.epos2.printer.ReceiveListener() {
@Override
public void onPtrReceive(Printer printer, int i, PrinterStatusInfo printerStatusInfo, String s) {
runOnUiThread(new Runnable() {
@Override
public synchronized void run() {
disconnectPrinter();
new Thread(new Runnable() {
@Override
public void run() {
disconnectPrinter();
}
}).start();
}
});
}
});
return true;
}
public void finalizeObject() {
if (mPrinter == null) {
return;
}
mPrinter.clearCommandBuffer();
mPrinter.setReceiveEventListener(null);
mPrinter = null;
}
public boolean printData(String receiptPrintIP) {
if (mPrinter == null) {
return false;
}
if (!connectPrinter(receiptPrintIP)) {
return false;
}
PrinterStatusInfo status = mPrinter.getStatus();
if (!isPrintable(status)) {
ShowMsg.showMsg(printPOS2Help.makeErrorMessage(status), mContext);
try {
mPrinter.disconnect();
}
catch (Exception ex) {
// Do nothing
}
return false;
}
try {
mPrinter.sendData(Printer.PARAM_DEFAULT);
}
catch (Exception e) {
ShowMsg.showException(e, "sendData", mContext);
try {
mPrinter.disconnect();
}
catch (Exception ex) {
// Do nothing
}
return false;
}
return true;
}
public boolean connectPrinter(String receiptPrintIP) {
boolean isBeginTransaction = false;
if (mPrinter == null) {
return false;
}
try {
mPrinter.connect(receiptPrintIP, Printer.PARAM_DEFAULT);
}
catch (Exception e) {
ShowMsg.showException(e, "connect", mContext);
return false;
}
try {
mPrinter.beginTransaction();
isBeginTransaction = true;
}
catch (Exception e) {
ShowMsg.showException(e, "beginTransaction", mContext);
}
if (isBeginTransaction == false) {
try {
mPrinter.disconnect();
}
catch (Epos2Exception e) {
// Do nothing
return false;
}
}
return true;
}