Printing from Android to a Bluetooth Zebra printer without pairing

I'm looking for a way to print from an Android device to a Zebra printer over bluetooth without previously pairing it.

 

The printer does not have an authentication PIN so pairing seems to have issues with the Android interface: https://code.google.com/p/android/issues/detail?id=26041

 

I've done some testing using the createInsecureRfcommSocketToServiceRecord API with mixed results. Using below code I'm able to print on the MZ320 from Android v4.1.2 devices but the same program fails on Android v4.4.3. So far I've tested:

 

  • MC40 JB v4.1.2 - Works
  • TC55 JB v4.1.2 - Works
  • TC70 KK v4.4.3 - Printer lights up blue led signaling a Bluetooth request but no printing
  • Nexus 7 (2012) KK v4.4.3 - Printer lights up blue led signaling a Bluetooth request but no printing

 

The only difference in the logs running the app is that I get this warning on KK devices:

11-06 12:10:05.824    2136-2178/com.pietromaggi.sample.printing W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback   11-06 12:10:05.834    2136-2178/com.pietromaggi.sample.printing D/BluetoothSocket﹕ connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[59]}  

But I don't think that this is what generate the issue:

core/java/android/bluetooth/BluetoothAdapter.java - platform/frameworks/base - Git at Google

 

Any idea/suggestion?

 

~Pietro

 

public void pairPrinter()  {           final UUID SerialPortServiceClass_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");           final BluetoothAdapter BA = BluetoothAdapter.getDefaultAdapter();           final String PrinterBsid = "00:22:58:0E:E7:87"; // This is My Printer Bluetooth MAC Address                 Thread t = new Thread(new Runnable() {               @Override               public void run() {                   OutputStream sOut;                   BluetoothSocket socket;                   BA.cancelDiscovery();                         BluetoothDevice BD = BA.getRemoteDevice(PrinterBsid);                   try {                       socket = BD.createInsecureRfcommSocketToServiceRecord(SerialPortServiceClass_UUID);                   } catch (IOException e) {                       return;                   }                         if (!socket.isConnected()) {                       try {                           socket.connect();                           sOut = socket.getOutputStream();   //                        sOut.write(("Hello World\n").getBytes());                           String cpclData = "! 0 200 200 210 1\r\n"                                   + "TEXT 4 0 30 40 This is a CPCL test.\r\n"                                   + "FORM\r\n"                                   + "PRINT\r\n";                           sOut.write(cpclData.getBytes());                           sOut.close();                       } catch (IOException e) {                           e.printStackTrace();                       }                   }                         try {                       Thread.sleep(1000);                       socket.close();                       BA.cancelDiscovery();                   } catch (IOException e) {                       e.printStackTrace();                   } catch (InterruptedException e) {                       e.printStackTrace();                   }               }           });                 t.start();       }