Learning How to Get Started with LinkOS Android SDK

James Kimball -
3 MIN READ

In this blog, we'll focus on how to get started with the Java Android Link-OS Software Development Kit (SDK). To make it easier, the SDK comes with free developer demos and an apk that can be loaded onto your Android device.

You can access all the Link-OS SDKs here.

To get started you will need to decide what type of Connection you want to make.  The Android SDK offers TCP/IP, Bluetooth, and USB On The Go (OTG) connections.  Let's focus on the Bluetooth connection from the examples today.

mainBtExample.PNG
mainBtExample.PNG, by JKimball

mainBtExample.PNG, by JKimball

In the snippet above, you first create a String that will be the Bluetooth MACAddress for the printer.  The Bluetooth MACAddress is the way one initializes the connection to the printer over Bluetooth.

Taking a look at sendZplOverBluetooth(String MACAddress) we can see how we create the Bluetooth connection to the printer.

zplWriteExample.PNG
zplWriteExample.PNG, by JKimball

zplWriteExample.PNG, by JKimball

To instantiate the Bluetooth Connection, you'll need to use line 25 from above and send in the MAC Address of the printer.  You will notice that we are not creating a BluetoothConnection object but rather a Connection object.  In the Link-OS SDKs, all connections are derived from a base Connection class making it easier to create applications that allow multiple types of connections without needing to create multiple classes to handle each connection type.

Once connected you'll  need to open it. To do that call thePrinterConn.open() on line 31 which will allow communication with the printer.

Now we are ready to write our ZPL data to the printer.  You can use the write directly from the connection like you see above on line 37, or you can create a ZebraPrinter object out of the connection which will allow you to do the most with your printer.

When working with our Link-OS SDK one of our best practices is checking the printer’s status before performing any print jobs.

PrinterStatusExample.png
PrinterStatusExample.png, by JKimball

PrinterStatusExample.png, by JKimball

In the example above, you'll  need to first create a ZebraPrinter object from the connection.  You can do this by using the ZebraPrinterFactory class to create a ZebraPrinter object (shown in line 17).  There is also a ZebraPrinterLinkOS object that can be created in the ZebraPrinterFactory as well, that provides you with LinkOS specific features for your applications.

Once you've got your ZebraPrinter, you can now call getCurrentStatus() to retrieve the PrinterStatus object from the printer (shown in line 19).  You'll know the printer is ready to print by checking the isReadyToPrint boolean in the PrinterStatus object (shown in line 20).

The ZebraPrinter and ZebraPrinterLinkOS objects have a lot of capabilities and are designed to select the best way to communicate with your printer.  Take a look through the documentation here and discover what you can accomplish as you build new applications for your printers.

profile

James Kimball

Please register or login to post a reply

1 Replies

J Juan Lara

It´s really difficult to read the code shown in images as it´s really small.