title: How to receive data via Bluetooth on Android?
body: <p>I read many topics, but I couldn't find good answer. I'm working on  Android application that uses Bluetooth to send and receive data from Microcontroller. I have already finished sending part and it works fine, but I have problem with receiving data on Android.
  I'm using this library: <a href="https://android-arsenal.com/details/1/690#!description" rel="nofollow">https://android-arsenal.com/details/1/690#!description</a> It doesn't have properly tutorial (or at least I don't see it), it just says about receiving data on android this:</p>
  
  <pre><code>//Listener for data receiving
  bt.setOnDataReceivedListener(new OnDataReceivedListener() {
      public void onDataReceived(byte[] data, String message) {
          // Do something when data incoming
      }
  });
  </code></pre>
  
  <p><strong>Does anybody have any idea how to use it?</strong> I have tried to write whole Bluetooth part by myself, but it was too hard, so I decided to use this library. I need to listen for incoming datas all the time, but also I can't do it in loop, because it will block the UI thread.</p>