Example usage for android.os Parcel unmarshall

List of usage examples for android.os Parcel unmarshall

Introduction

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

Prototype

public final void unmarshall(byte[] data, int offset, int length) 

Source Link

Document

Set the bytes in data to be the raw bytes of this Parcel.

Usage

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 . j av  a2  s  .c om
    Bundle result = Bundle.CREATOR.createFromParcel(obtain);
    obtain.recycle();
    return result;
}

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   ww  w .  j  a  v a  2  s.c  om*/
    ContentValues createFromParcel = ContentValues.CREATOR.createFromParcel(obtain);
    obtain.recycle();
    return createFromParcel;
}

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  w w .  j a  v a2 s. c o  m
    return parcel;
}

From source file:Main.java

public static Intent intentFromByteArray(byte[] byteArray) {
    Parcel obtain = Parcel.obtain();
    obtain.unmarshall(byteArray, 0, byteArray.length);
    obtain.setDataPosition(0);/* www . java2 s. c  om*/
    Intent createFromParcel = Intent.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);// 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 Parcel unmarshall(byte[] bytes) {
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);//  ww w.j a v  a  2  s . c  o  m
    return parcel;
}

From source file:Main.java

private static <T> T bytes2Parcelable(final byte[] bytes, final Parcelable.Creator<T> creator) {
    if (bytes == null)
        return null;
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);//from ww w  .  ja  v  a  2  s  . c om
    T result = creator.createFromParcel(parcel);
    parcel.recycle();
    return result;
}

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 www  . j  a v a  2  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;
}

From source file:Main.java

public static Parcel unmarshall(byte[] bytes) {
    Parcel parcel = Parcel.obtain();

    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);// ww  w .  ja  va 2 s.c o  m

    return parcel;
}

From source file:Main.java

public static Bundle mutate(Bundle bundle) {

    if (bundle == null) {
        return null;
    }//  w  ww .  jav  a  2s  . c  om

    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();
    }
}