In the Java Printing library, the LabelPrinter class represents a label printer and provides methods to communicate with the printer. To print a label, the application needs to perform the following steps:
Android OS displays the "Application Not Responding" (ANR) message if the application performs a lengthy operation (about 5 seconds) on the UI thread. While this occurs, the system cannot process incoming user input events. The printing API communicates with the printer through a network connection, which may invoke unpredictable delays that result in the ANR message.
To prevent the ANR message, the LabelPrinter constructors and methods must be called on a separate thread on the Android platform. The only exceptions are the methods that add or remove an event listener. Most LabelPrinter methods throw a LabelPrinterException if called from the UI thread.
Sample code is included in the Print a Label section. The Honeywell Mobility Android Printing SDK also includes a sample application called LabelPrinterSample.