title: Android InputStream cannot receive the whole message from Bluetooth HC-05
body: <p>My Problem is to receive data from android app I send data from Arduino which is like that {166;122;33;5;n}
  and when I open a socket with Android it jus receive the first 9 or 10 bytes and show me the data like that 166;122;33. 
  want to know how to receive it all in InputStream.
  the function that responsible for that is beginListenForData() here it's.</p>
  
  <hr>
  
  <pre><code>  void beginListenForData() {
      final Handler handler = new Handler();
      stopThread = false;
      Thread thread = new Thread(new Runnable() {
          public void run() {
              while (!Thread.currentThread().isInterrupted() &amp;&amp; !stopThread) {
                  try {
                      final int byteCount = inputStream.available();
                      if (byteCount &gt; 0) {
                          byte[] rawBytes = new byte[byteCount];
                          inputStream.read(rawBytes);
                          final String str = new String(rawBytes);
                          handler.post(new Runnable() {
                              public void run() {
                                  if (str.charAt(0) == '{') {
                                      try {
                                          bytes = inputStream.read(buffer, 0, 
                                                                   buffer.length);
                                          String readMessage1 = new String(buffer,   
                                                            0, bytes, "US-ASCII");
                                          Log.e("bytes ",  
                                                Integer.toString(bytes));
                                          Log.e("tag:", readMessage1);
                                          sendMessage(readMessage1);
  
                                      } catch (IOException e) {
                                          e.printStackTrace();
                                          Log.e("tag", "failed");
                                      }
                                  }
  
  
                              }
                          });
  
                      }
                  } catch (IOException ex) {
                      sendMessage("F");
                      stopThread = true;
                  }
              }
          }
      });
  
      thread.start();
  }
  </code></pre>