title: ByteBuffer throws UnsupportedOperationException on certain version of Android
body: <p>I'm writing some simple networking code which involves working with ByteBuffers. For some reason, the following code throws an UnsopportedOperationException on two of my test devices:</p>
  
  <pre><code>int send = Integer.parseInt(edtxt.getText().toString());
  
  OutputStream out = sock.getOutputStream();
  
  ByteBuffer buf = ByteBuffer.allocateDirect(1);
  buf.order(ByteOrder.BIG_ENDIAN);
      buf.put((byte)send);
      buf.rewind();
  byte[] outa = buf.array(); //Exception thrown here
  out.write(outa);
  </code></pre>
  
  <p>The two devices it fails on are:</p>
  
  <ul>
  <li><p>Sony Ericsson Xperia Play running Android 2.3.3</p></li>
  <li><p>Motorla Droid X2 running Android 2.3.5</p></li>
  </ul>
  
  <p>The two it works on are:</p>
  
  <ul>
  <li><p>LG G3 running Android 4.4.2</p></li>
  <li><p>Nexus 4 running Android 4.4.4</p></li>
  </ul>
  
  <p>The docs say that UnsupportedOperationException will be thrown if the byte buffer isn't based on an array. Is this a difference between Gingerbread and KitKat that I just need to deal with, or is it just a case of bad practice?</p>