title: How to break an object into a byte[]?
body: <p>How do I break an object --- a Parcelable to be more specific; actually it's a bundle but the point is the same --- into a byte[]? I thought that the way I was doing it was a good solution but apparently I was mistaken.</p>
  
  <p>Just for reference here is the old way I was doing it.</p>
  
  <pre><code>public static byte[] getBytes(Object obj) throws java.io.IOException {
      ByteArrayOutputStream bos   = new ByteArrayOutputStream();
      ObjectOutputStream oos      = new ObjectOutputStream(bos);
      oos.writeObject(obj);
      oos.flush();
      oos.close();
      bos.close();
      byte[] data = bos.toByteArray();
      return data;
  }
  </code></pre>
  
  <p>Thanks ~Aedon</p>
  
  <p>Edit 1::</p>
  
  <p>Breaking an object like this passing a Bundle to it causes a NotSerializableException.</p>