pack Serializable to Bundle - Android Android OS

Android examples for Android OS:Bundle

Description

pack Serializable to Bundle

Demo Code


//package com.book2s;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.io.Serializable;

public class Main {
    public static Bundle pack(@NonNull final Bundle bundle,
            @NonNull final String key,
            @Nullable final Serializable serializable) {
        if (serializable != null) {
            bundle.putSerializable(key, serializable);
        }//from  w ww.  j a v  a  2s  . c o m
        return bundle;
    }

    public static Bundle pack(@NonNull final String key,
            @Nullable final Serializable serializable) {
        final Bundle bundle = new Bundle();
        return pack(bundle, key, serializable);
    }
}

Related Tutorials