I'm transfering positive integers between 0 and 10000 between my Android phone and my Arduino. 
Since the serial sends a byte array, I've to convert the sent byte array back to an integer.

But everything I tried does either throw a 

> 
> java.nio.BufferUnderflowException
> 
> 
> 

or returns a wrong value (my Arduino sends 150, I get -106)!

I tried it with ByteBuffer:

```
@Override
public void onNewData(final byte[] data) {
   runOnUiThread(new Runnable() {
        @Override
        public void run() {
            editText.append("Read: " + ByteBuffer.allocate(4).put(data).getInt());
        }
    });
}

```

And I tried it for values smaller 255 (the 150 I mentionend before):

```
@Override
public void onNewData(final byte[] data) {
   runOnUiThread(new Runnable() {
        @Override
        public void run() {
            editText.append("Read: " + new Byte(data[0]).intValue());
        }
    });
}

```

The Arduino sends the following:

```
uint16_t iSend = 150;

void loop() {
  Serial.write(iSend);

  delay(1000);
}

```

And my android phone reads the following:

```
D/SerialInputOutputManager: Read data len=1
D/UsbRequestJNI: init
D/UsbRequestJNI: close
D/UsbRequestJNI: init
I/System.out: 0x00000000 96

```

Did anyone solve a similar problem?
Thanks in advance!