¡@

Home 

2014/10/16 ¤W¤È 08:21:12

android Programming Glossary: parcel.obtain

How to use Parcel in Android?

http://stackoverflow.com/questions/1626667/how-to-use-parcel-in-android

null . public void testFoo final Foo orig new Foo blah blah Wrote orig to a parcel and then byte array final Parcel p1 Parcel.obtain p1.writeValue orig final byte bytes p1.marshall Check to make sure that the byte array seems to contain a Parcelable assertEquals.. a Parcelable assertEquals 4 bytes 0 Parcel.VAL_PARCELABLE Unmarshall a Foo from that byte array final Parcel p2 Parcel.obtain p2.unmarshall bytes 0 bytes.length final Foo result Foo p2.readValue Foo.class.getClassLoader assertNotNull result FAIL.. your data. Here is the revised working code public void testFoo final Foo orig new Foo blah blah final Parcel p1 Parcel.obtain final Parcel p2 Parcel.obtain final byte bytes final Foo result try p1.writeValue orig bytes p1.marshall Check to make sure..

How to serialize a Bundle?

http://stackoverflow.com/questions/2598248/how-to-serialize-a-bundle

to a file is very easy FileOutputStream fos context.openFileOutput localFilename Context.MODE_PRIVATE Parcel p Parcel.obtain i make an empty one here but you can use yours fos.write p.marshall fos.flush fos.close enjoy share improve this answer..

Elegant way to read file into byte[] array in Java [duplicate]

http://stackoverflow.com/questions/6058003/elegant-way-to-read-file-into-byte-array-in-java

index total_size break and clear chunks array chunks.clear finally I can unmarshall this data to Parcel Parcel parcel Parcel.obtain parcel.unmarshall rawdata 0 rawdata.length I think this code looks ugly and my question is How to do read data from file..