Zebra ZD610 printer using Android to print

F Farhad Bhuiyan 2 years 5 months ago
26 0 0

Hi,
I'm developing an Android app to print on a zebra linkOS 6.7 label printer device. Here is the code i'm using--

new Thread(new Runnable() {
public void run() {
Connection thePrinterConn = null;
try {
thePrinterConn = new BluetoothLeConnection(theBtMacAddress, context);
thePrinterConn.open();
thePrinterConn.write(zplData.getBytes());
Thread.sleep(1000);
} catch (final Exception e) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});

} finally {
if (null != thePrinterConn) {
try {
thePrinterConn.close();
} catch (final Exception e) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d("TAG", e.getMessage());
Toast.makeText(context, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});

}
} else {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, "No printer connection", Toast.LENGTH_SHORT).show();
}
});
}
}
}
}).start();

My problem is, it prints for a few times, and then gives a connection error and doesn't print.
Please let me know if there's a solution. Thanks in advance.

CONTACT
Can’t find what you’re looking for?