4 Replies Latest reply on Aug 31, 2017 8:02 AM by Robin West

    Can't print over Bluetooth from Android to a ZD420 using ZSDK

    Colin Anderson



      I'm trying to print to a ZD420 label printer using Bluetooth from an Android app I am developing. I've been using the sample apps to guide me, but I can't get them to connect to the printer.


      The following code throws a ConnectionException:


      public class ZebraActivity extends AppCompatActivity {
         protected void onCreate(Bundle savedInstanceState) {
        String theBtMacAddress = "7C:EC:79:33:E3:89";
        Context context = getApplicationContext();
        sendZplOverBluetoothLe(theBtMacAddress, context);
         private void sendZplOverBluetoothLe(final String theBtMacAddress, final Context context) {
         new Thread(new Runnable() {
         public void run() {
        Connection thePrinterConn = null;
         try {
         // Instantiate connection for given Bluetooth® MAC Address.
         thePrinterConn = new BluetoothConnectionInsecure(theBtMacAddress);
         // Open the connection - physical connection is established here.
         // This example prints "This is a ZPL test." near the top of the label.
         String zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";
         // Send the data to printer as a byte array.
         // Make sure the data got to the printer before closing the connection
        } catch (Exception e) {
         // Handle communications error here.
        } finally {
         // Close the connection to release resources.
         if (null != thePrinterConn) {
         try {
        } catch (ConnectionException e) {

      Results in Stacktrace:

      08-08 12:45:40.879 24427-24445/xxxW/System.err: com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1

      08-08 12:45:40.879 24427-24445/xxx W/System.err:     at com.zebra.sdk.comm.ConnectionA.open(Unknown Source)

      08-08 12:45:40.879 24427-24445/xxx W/System.err:     at com.zebra.sdk.comm.BluetoothConnection.open(Unknown Source)

      08-08 12:45:40.879 24427-24445/xxxW/System.err:     at com.hermesinnovationlab.hermesreturns.zebra.ZebraActivity$1.run(ZebraActivity.java:41)

      08-08 12:45:40.879 24427-24445/xxx W/System.err:     at java.lang.Thread.run(Thread.java:818)

      08-08 12:45:40.879 24427-24445/xxx W/System.err: Caused by: com.zebra.sdk.comm.ConnectionException: read failed, socket might closed or timeout, read ret: -1

      08-08 12:45:40.879 24427-24445/xxx W/System.err:     at com.zebra.sdk.comm.internal.BluetoothInsecureZebraConnectorImpl.tryPublicApiWay(Unknown Source)

      08-08 12:45:40.879 24427-24445/xxx W/System.err:     at com.zebra.sdk.comm.internal.BluetoothInsecureZebraConnectorImpl.open(Unknown Source)

      08-08 12:45:40.879 24427-24445/xxx W/System.err: ... 4 more


      I'm running the app on a Samsung Galaxy A6 with Android 5.1.1.

      The manifest has the following permissions set:

      <uses-permission android:name="android.permission.BLUETOOTH" />

      <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


      Can anyone offer me any advice as to how I can get this working? Event the Zebra sample app doesn't connect to the printer.