Puts boolean value to bundle if passed and creates empty Bundle if null passed - Android android.os

Android examples for android.os:Bundle

Description

Puts boolean value to bundle if passed and creates empty Bundle if null passed

Demo Code

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

public class Main{

    /**/*ww  w  .  jav  a 2 s  .  c om*/
     * Puts boolean value to bundle if passed and creates it if {@code null} passed.
     *
     * @param bundle to put into
     * @param key    to to put under
     * @param value  to put
     * @return bundle with the newly put value
     */
    public static Bundle putBoolean(Bundle bundle, String key, Boolean value) {
        if (bundle == null) {
            bundle = new Bundle();
        }
        bundle.putBoolean(key, value);
        return bundle;
    }
}

Related Tutorials