read List From Parcel - Android android.os

Android examples for android.os:Parcel

Description

read List From 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;

    @SuppressWarnings("unchecked")
    public static <T extends Parcelable> List<T> readListFromParcel(
            Parcel in, Class<T> cls) {
        int flag = in.readInt();
        if (flag == EXIST_SEPARATOR) {
            return in.readArrayList(cls.getClassLoader());
        } else {/*from  w  w w  .j a  v a 2s .c  o  m*/
            return null;
        }
    }
}

Related Tutorials