title: Using the serial port ttyUSB0 in Android with Digi Xbee Java Api
body: <p>I am making an Android app in Odroid Xu4, connected to it is the Xbee Pro s2 via usb serial converter with cp210x driver using ttyUBS0 port but inside the app it disconnects from ttyUBS0 and uses bus /dev/bus/usb/.. 
  No I have to open the serial port to access Rx/Tx for xbee. I am right now using usb-serial-for-android <a href="https://github.com/mik3y/usb-serial-for-android/tree/master/usbSerialExamples" rel="nofollow">https://github.com/mik3y/usb-serial-for-android/tree/master/usbSerialExamples</a></p>
  
  <p>But its not helping much, my app crash as soon as open the xbee device. 
  Here is my code</p>
  
  <pre><code> List&lt;UsbSerialDriver&gt; availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager);
      if (availableDrivers.isEmpty()) {
          return;
      }
  
      UsbSerialDriver driver = availableDrivers.get(0);
      Toast.makeText(this, "connection done" + driver, Toast.LENGTH_LONG).show();
      List&lt;UsbSerialPort&gt; availableports = driver.getPorts();
      for (UsbSerialPort port : availableports) {
          Toast.makeText(this, "port please :" + port.getPortNumber(), Toast.LENGTH_LONG).show();
          UsbDeviceConnection connection = manager.openDevice(driver.getDevice());
          try {
              port.open(connection);
              Toast.makeText(this," yes i m connected to port", Toast.LENGTH_LONG).show();
              port.setParameters(BAUDRATE, 8, 1, 0);
              Toast.makeText(this," baudrate set", Toast.LENGTH_LONG).show();
              PORT = driver.getDevice().toString();
              if (PORT == null) {
                  Toast.makeText(this, "not connected",Toast.LENGTH_LONG).show();
              }
              else
              {
                  XBeeDevice mydevice = new XBeeDevice(PORT, BAUDRATE);
                  Toast.makeText(this, "connected",Toast.LENGTH_LONG).show();
                  try {
                      mydevice.open(); //App crashes now :(
                      Toast.makeText(this, "connected woow",Toast.LENGTH_LONG).show();
                  } catch (XBeeException e) {
                      e.printStackTrace();
                  }
              }
  
  
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>Can someone guide. Am I doing something wrong in the code? Here is another library i found <a href="http://antipastohw.pbworks.com/w/page/41729078/How-to%20use%20a%20serial%20port%20with%20Android,%20Liquidware%20Ambrosia%20edition" rel="nofollow">http://antipastohw.pbworks.com/w/page/41729078/How-to%20use%20a%20serial%20port%20with%20Android,%20Liquidware%20Ambrosia%20edition</a>
  Can it be helpful?</p>