Retrieves boolean value from bundle if present - Android android.os

Android examples for android.os:Bundle

Description

Retrieves boolean value from bundle if present

Demo Code

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

public class Main{

    public static final boolean DEFAULT_BOOLEAN_VALUE = false;
    /**/*w  ww . jav a  2s .  c  o  m*/
     * Retrieves boolean value from bundle if present.
     *
     * @param bundle to get from
     * @param key    to search by
     * @return value or {@link #DEFAULT_STRING_VALUE} if nothing found
     */
    public static Boolean getBoolean(Bundle bundle, String key) {
        if (bundle != null && bundle.containsKey(key)) {
            return bundle.getBoolean(key);
        } else {
            return DEFAULT_BOOLEAN_VALUE;
        }
    }

}

Related Tutorials