4 Replies Latest reply on Jan 17, 2017 3:25 PM by Manuel Caicedo-Rivera


    Graham Wright

      I have implemented the code contained in the SDL documentation for UsbDiscoverer.

      However the UsbDiscoveryHandler.discoveryFinished() fires without ever finding the attached USB printer (neither UsbDiscoveryHandler.foundPrinter or discoveryError fire)


      I am connected to a iMZ220 and want to provide an option to use USB rather then Bluetooth.

      I have added to USB_PERMISSUION to my manifest.

      I am currently connecting the Android device and the printer via a USB hub pending delivery of a USM mini to micro cable which may be an issue.


      Any ideas why the discovery fails to find the printer ?

        • Re: UsbDiscoverer
          Robin West

          Hi Graham,

          You do need to use a USB "On The Go" cable to connect the Android to the printer.  Other than that, there is a lot of setup needed to do USB discovery.  If you are following the code in the Android SDK documentation for using USB, then I would say it's likely your cable.

          Hope this helps,


            • Re: UsbDiscoverer
              Graham Wright

              I have tried using an “On The Go” cable but still have the same behaviour.

              Once findPrinters is called discoveryFinished is fired without any foundPrinter events.

              There are no exceptions when findPrinters is called nor is dscoveryError called on the UsbDiscoveryHandler.

              This behaviour occurs both in my original app and in a test app which is essentially the code in the API documentation.

              Debugging is obviously difficult as the USB cable is connected to the iMZ220 rather than my development computer so I have recorded events in a list and displayed these once the discovery process has completed.


              The relevant sections of my test app are


              class UsbDiscoveryHandler implements DiscoveryHandler {

                 public List<DiscoveredPrinterUsb> printers;


                 public UsbDiscoveryHandler() {

                 printers = new LinkedList<DiscoveredPrinterUsb>();



                 public void foundPrinter(final DiscoveredPrinter printer) {

                 _debugMessages.add("Found printer");

                 printers.add((DiscoveredPrinterUsb) printer);



                 public void discoveryFinished() {

                 _debugMessages.add("Discovery finished");



                 public void discoveryError(String message) {


                 _debugMessages.add("Error: " + message);





              public void onClickPermission(View v)



                 _debugMessages = new ArrayList<String>();


                 new Thread(new Runnable() {


                 public void run() {

                 // Find connected printers

                UsbDiscoveryHandler handler = new UsbDiscoveryHandler();

                 _debugMessages.add("Calling findPrinters");

                 try {

                UsbDiscoverer.findPrinters(getApplicationContext(), handler);

                 if (handler.printers != null && handler.printers.size() > 0) {

                 discoveredPrinterUsb = handler.printers.get(0);

                 mUsbManager.requestPermission(discoveredPrinterUsb.device, mPermissionIntent);

                } else {

                 _debugMessages.add("No printers found");



                } catch (Exception e) {

                 _debugMessages.add("Exception: " + e.getMessage());

                } finally {






              • Re: UsbDiscoverer
                Graham Wright

                I have tried the code on a Galaxy Core smart phone running Android 5.0 and a Galaxy tab running Android 4.4 using a "On the Go" cable.

                In neither case does the code work.

                On the Galaxy Core the discovery calls discoveryFinished without ever calling foundPrinter.

                The Galaxy core found the printer once and then failed on subsequent attempts, even after re-installing the test app.


                USB discovery is not implemented in the TestConnect, PrintConnect and PrintStation sample apps from Zebra.

                USB discovery is not implemented "ZSDK Developer Demos" source code included in the Zebra SDK.

                Does this indicate that USB discovery and printing  is deprecated and/or unstable ?

                  • Re: UsbDiscoverer
                    Manuel Caicedo-Rivera

                    Hi Graham,


                    In order for USB Discovery to work, the printer must be connected to the Android device with an On-the-go adapter.  In addition, the specific Android device must have built in support for On-the-go devices.  One way to quickly determine if this is working properly is to plug in a keyboard to the On-the-go adapter.  If the keyboard is functional inside Android, then the setup should be fine.


                    If the device has support, and the printer is connected via the correct cable, then USB discovery should work.  USB discovery is built in to several of our applications (Print Station, Zebra Printer Setup Utility, etc), and we have tested the USB functionality on a wide range of Android devices. We have no plans to deprecate this feature.


                    A quick sample of USB discovery can be found in the Javadoc for the UsbDiscoverer class.  A more real-world implementation can be found inside of the Print Station source, which is bundled with the SDK.