add value to Bundle If Not Null - Android android.os

Android examples for android.os:Bundle

Description

add value to Bundle If Not Null

Demo Code

import android.os.Bundle;
import android.text.TextUtils;
import java.io.Serializable;

public class Main{

    public static void addIfNotNull(Bundle b, String key, Serializable value) {
        if (value != null) {
            b.putSerializable(key, value);
        }//from w w w  .j  ava2 s . c  o  m
    }
    public static void addIfNotNull(Bundle b, String key, Integer value) {
        if (value != null) {
            b.putInt(key, value);
        }
    }

}

Related Tutorials