write List To Parcel - Android android.os

Android examples for android.os:Parcel

Description

write List To Parcel

Demo Code


//package com.java2s;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.List;

public class Main {
    final static int EXIST_SEPARATOR = 1;
    final static int NON_SEPARATOR = 0;

    @SuppressWarnings("unchecked")
    public static <T extends Parcelable> void writeListToParcel(Parcel out,
            List<T> collection) {
        if (collection != null) {
            out.writeInt(EXIST_SEPARATOR);
            out.writeParcelableArray((T[]) collection.toArray(), 0);
        } else {/*from   w  w  w . j  ava2s  .  co m*/
            out.writeInt(NON_SEPARATOR);
        }
    }
}

Related Tutorials