parcelable From Byte Array - Android android.os

Android examples for android.os:Parcel

Description

parcelable From Byte Array

Demo Code


//package com.java2s;

import android.os.Parcel;
import android.os.Parcelable;

public class Main {
    public static <T extends Parcelable> T parcelableFromByteArray(
            Parcelable.Creator<T> creator, byte[] byteArray) {
        Parcel obtain = Parcel.obtain();
        obtain.unmarshall(byteArray, 0, byteArray.length);
        obtain.setDataPosition(0);// w  w  w .j av a 2  s  . c o m
        T createFromParcel = creator.createFromParcel(obtain);
        obtain.recycle();
        return createFromParcel;
    }
}

Related Tutorials