get Parcelable from Bundle - Android Android OS

Android examples for Android OS:Parcel

Description

get Parcelable from Bundle

Demo Code


import java.util.ArrayList;
import android.os.Bundle;
import android.os.Parcelable;

public class Main{
    private static final String TAG = BundleUtils.class.getSimpleName();
    public static <T extends Parcelable> T getParcelable(String key,
            Bundle... bundles) {// www. j ava 2  s.  com
        if (bundles != null) {
            for (Bundle bundle : bundles) {
                if (bundle != null && bundle.containsKey(key)) {
                    return bundle.getParcelable(key);
                }
            }
        }
        MTLog.d(TAG,
                "Can't find the parcelable value for key '%s' (returned null)",
                key);
        return null;
    }
}

Related Tutorials