4 Replies Latest reply on Mar 16, 2016 3:39 AM by Graham Wright

    Failure of USB connection on Android apps

    Graham Wright

      I am still waiting for a response on this question

      UsbDiscoverer but it seems that only new questions are monitored not subsequent replies

        • Re: Failure of USB connection on Android apps
          Gregory Pawlik

          Hi Graham,

           

          My apologies for the late response.

           

          First, make sure that you USB OTG is working on your Android device.

          You should be able to plug in a USB keyboard or mouse and be able to control your device with it.

           

          In regards to the PrintStation app, although it does not use the UsbDiscoverer class it does use the DiscoveredPrinterUsb class which may be a better option.

          Refer to the DiscoveredPrinterListAdapter.java in the PrintStation project.

          You can load the PrintStation app on your Android device and connect the iMZ via USB OTG and give the app a try in printing to the printer.

           

          Greg

            • Re: Failure of USB connection on Android apps
              Graham Wright

              I must be missing something.

              The code for the PrintStation app seems to use the same UsbDiscoverer.findPrinters, UsbManager etc as the sample code in the API documentation.

              Is the behaviour of the PrintStation expected to be different from a standalone app implementing the API sample code ?

                • Re: Failure of USB connection on Android apps
                  Gregory Pawlik

                  Both apps should behave the same in terms of being able to connect to a Zebra printer via USB from an android device.

                  The PrintStation app provides a working example how to use the USB sample code in the documentation.

                   

                  Is the PrintStation app working on your Android device?

                    • Re: Failure of USB connection on Android apps
                      Graham Wright

                      Thanks for your assistance, I now have things working.

                       

                      There where three issues;

                      1)

                      USB OTG is not supported on all Samsung devices (specifically the Galaxy Core phone)

                       

                      2)

                      The sample code only works once because mUsbManager.requestPermission does not result in a call to mUsbReceiver to set the hasPermissionToCommunicate if permission already exists.

                      The code should be something like

                          if (mUsbManager.hasPermission(discoveredPrinterUsb.device)) {

                                   hasPermissionToCommunicate = true;

                           }

                           else {

                                mUsbManager.requestPermission(discoveredPrinterUsb.device, mPermissionIntent);

                           }

                       

                      3)

                      The sample code print command, conn.write("~WC".getBytes()), only results in output on my iMZ220 once and needs to be replaced by a more extensive command depending on the printer being used and the mode required.