Example usage for android.os Parcel marshall

List of usage examples for android.os Parcel marshall

Introduction

In this page you can find the example usage for android.os Parcel marshall.

Prototype

public final byte[] marshall() 

Source Link

Document

Returns the raw bytes of the parcel.

Usage

From source file:Main.java

public static byte[] serialize(Parcelable parceable) {
    Parcel parcel = Parcel.obtain();
    parceable.writeToParcel(parcel, 0);// w  w  w  .j  a  v  a  2  s .  c o m
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    return bytes;
}

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();//from   w  w  w  . j a  va  2s .  c o m
    return bytes;
}

From source file:Main.java

public static byte[] marshall(Object value) {
    if (value == null) {
        return null;
    }//from  w  w w .j ava2 s.co m

    Parcel parcel = Parcel.obtain();
    try {
        parcel.writeValue(value);
        return parcel.marshall();
    } finally {
        parcel.recycle();
    }
}

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();//  ww  w .j  a  v a  2 s  .  c om
    return byteArray;
}

From source file:Main.java

public static byte[] marshall(Parcelable parcelable) {
    Parcel parcel = Parcel.obtain();

    parcelable.writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    parcel.recycle();//from w w  w .  j a va  2  s  .  c  o m

    return bytes;
}

From source file:Main.java

public static Bundle mutate(Bundle bundle) {

    if (bundle == null) {
        return null;
    }/*from  ww  w .ja va 2s.co  m*/

    final Parcel in = Parcel.obtain();
    in.writeBundle(bundle);
    final byte[] bytes = in.marshall();

    final Parcel out = Parcel.obtain();
    out.unmarshall(bytes, 0, bytes.length);
    out.setDataPosition(0);

    try {
        return out.readBundle();
    } finally {
        in.recycle();
        out.recycle();
    }
}

From source file:Main.java

public static byte[] toByteArray(Bundle bundle) {
    Parcel obtain = Parcel.obtain();
    bundle.writeToParcel(obtain, 0);/* w  ww . j  a  va  2s. c  om*/
    byte[] byteArray = obtain.marshall();
    obtain.recycle();
    return byteArray;
}

From source file:Main.java

public static byte[] toByteArray(Intent intent) {
    Parcel obtain = Parcel.obtain();
    intent.writeToParcel(obtain, 0);//from   w ww .java  2  s .  c  o m
    byte[] byteArray = obtain.marshall();
    obtain.recycle();
    return byteArray;
}

From source file:Main.java

public static byte[] toByteArray(ContentValues contentValues) {
    Parcel obtain = Parcel.obtain();
    contentValues.writeToParcel(obtain, 0);
    byte[] byteArray = obtain.marshall();
    obtain.recycle();/*from www .j a  va  2 s  .  co  m*/
    return byteArray;
}

From source file:Main.java

public static byte[] toByteArray(Spanned spanned) {
    Parcel obtain = Parcel.obtain();
    TextUtils.writeToParcel(spanned, obtain, 0);
    byte[] byteArray = obtain.marshall();
    obtain.recycle();/*from  www  .j  a  v  a 2 s .  c  o  m*/
    return byteArray;
}