unpack Bundle to Serializable - Android Android OS

Android examples for Android OS:Bundle

Description

unpack Bundle to Serializable

Demo Code


import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.io.Serializable;

public class Main{
    @Nullable/* w  w w.  java2s.c  o m*/
    public static Serializable unpack(@NonNull final Bundle bundle,
            @NonNull final String key) {
        if (!bundle.containsKey(key)) {
            LogHelper.warning("Bundle has no such key");
            return null;
        }

        return bundle.getSerializable(key);
    }
}

Related Tutorials