title: Android to Arduino USB Communication: Reading
body: <p>I've been looking at examples and I'm still not clear on how to actually read data from the usb port in my Android application. I'd like it to be event/intent driven but I'm pretty lost on how to do this. I have a BroadcastReceiver but I'm unsure what Intent.action I need to be looking for to catch data coming in. Any insight is appreciated!</p>
  
  <p>Edit: To clarify my Android device is a Nexus 9 running as a USB Host and I'm looking to communicate with an Arduino Leonardo.</p>
  
  <p>Edit2: At this point I have an Arduino sketch running sending a message over serial every 2 seconds. I have a button that based off of my understanding should read the buffer when pressed but doesn't actually do anything. </p>
  
  <pre><code>    TextView displayMessages = (TextView)findViewById(R.id.textView);
  
      try
      {
          byte[] msgBytes = new byte[1000];
          connection.bulkTransfer(input, msgBytes, msgBytes.length, TIMEOUT);
  
          String msgString = new String(msgBytes, "UTF-8");// msgBytes.toString();
          displayMessages.setText(msgString);
      }
      catch (Exception e)
      {
          displayMessages.setText(e.getMessage());
      }
  </code></pre>
  
  <p>The result is simply that the textView is blank. If I don't do the conversion and drop the byte[].toString() in I get hex values that change each press but I'm not sure how to interpret that.</p>
  
  <p>Edit 3: Just some more information as some time has passed, I have disabled the Arduino Leonardo showing up as an HID keyboard input device as per <a href="https://stackoverflow.com/questions/19208731/arduino-being-recognized-as-keyboard-by-android/21842455#21842455">Arduino being recognized as keyboard by android</a>. I simply modified the USBDesc.h to remove "#define HID_ENABLED". This didn't change the situation. In the meantime I have also implemented the Physicaloid USB library and that proved unsuccessful as well. I am in the process of debugging/converting mik3y's USB-serial-for-android library but have so far been unable to test with it. </p>