We do "Store and Recall print" to ZQ320 printers from Android tablets over Bluetooth. Looking at http://link-os.github.io/android/v2.9.2275/documentation/com/zebra/sdk/…, there is a comment stating we have to wait to make sure the data got to printer before closing connection.
// Make sure the data got to the printer before closing the connection
Thread.sleep(500);
Is there a better way to know when printer received all data? Waiting doesn't give confidence that the printer received data. We send files of different sizes, so waiting certain period of time for all files is not ideal.
5 Replies
The time used for the delay in the example code does appear arbitrary. But the essence is to ensure all the data are sent out and then received by the printer, before we close the connection. This is because that the Android OS doesn't tell the application whether the data has been sent and received completely.
A better way is to check the status of the printer (i.e. getCurrentStatus()) to make sure the following conditions are met before closing the connection.
Thanks @SSi1. Let me try that and get back to you.
Hi @SSi1, we tried the solution, when the Bluetooth Data Transfer is in progress, printer.getCurrentStatus() is throwing Malformed status exception. So we are trying something like this and it seems to work. Please confirm checking for status multiple times during Bluetooth Data transfer does not impede the actual data transfer.
Also it would be nice to have the samples updated with this.
Hi Laks, It's ok to call the getCurrentStatus() multiple times when it hits Malformed status response. The code flow looks good.
Thanks for confirming SSi1.