List of usage examples for android.os Parcel obtain
public static Parcel obtain()
From source file:Main.java
public static byte[] marshall(Object value) { if (value == null) { return null; }/*from w ww . ja v a 2s . c o m*/ Parcel parcel = Parcel.obtain(); try { parcel.writeValue(value); return parcel.marshall(); } finally { parcel.recycle(); } }
From source file:Main.java
public static Parcel deserialize(byte[] bytes) { Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0);//from w ww. ja v a2s .c o m return parcel; }
From source file:Main.java
public static Bundle bundleFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0);/*from ww w . jav a 2 s . com*/ Bundle result = Bundle.CREATOR.createFromParcel(obtain); obtain.recycle(); return result; }
From source file:Main.java
public static byte[] serialize(Parcelable parceable) { Parcel parcel = Parcel.obtain(); parceable.writeToParcel(parcel, 0);//from w ww . j av a 2 s .c o m byte[] bytes = parcel.marshall(); parcel.recycle(); return bytes; }
From source file:Main.java
public static Intent intentFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0);/*from ww w .ja v a 2s .com*/ Intent createFromParcel = Intent.CREATOR.createFromParcel(obtain); obtain.recycle(); return createFromParcel; }
From source file:Main.java
public static byte[] arrayToByteArray(ContentValues[] contentValues) { Parcel obtain = Parcel.obtain(); obtain.writeParcelableArray(contentValues, 0); byte[] byteArray = obtain.marshall(); obtain.recycle();/*from w ww . j a v a 2s .c om*/ return byteArray; }
From source file:Main.java
public static ContentValues contentValuesFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0);//from w w w. j av a2 s . co m ContentValues createFromParcel = ContentValues.CREATOR.createFromParcel(obtain); obtain.recycle(); return createFromParcel; }
From source file:Main.java
public static Spanned spannedFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0);//from w w w . ja v a 2 s. c o m Spanned result = (Spanned) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(obtain); obtain.recycle(); return result; }
From source file:Main.java
private static byte[] parcelable2Bytes(final Parcelable parcelable) { if (parcelable == null) return null; Parcel parcel = Parcel.obtain(); parcelable.writeToParcel(parcel, 0); byte[] bytes = parcel.marshall(); parcel.recycle();/* ww w . j ava2 s . c o m*/ return bytes; }
From source file:Main.java
public static ContentValues[] arrayContentValuesFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0);/*from w w w . j a va2 s . c om*/ Parcelable[] contentValues = obtain.readParcelableArray(ContentValues.class.getClassLoader()); ContentValues[] values = new ContentValues[contentValues.length]; for (int i = 0; i < contentValues.length; i++) { values[i] = (ContentValues) contentValues[i]; } obtain.recycle(); return values; }