Retrieves string value from bundle if present. - Android Android OS

Android examples for Android OS:Bundle Get

Description

Retrieves string value from bundle if present.

Demo Code


//package com.book2s;
import android.os.Bundle;

public class Main {
    public static final boolean DEFAULT_BOOLEAN_VALUE = false;

    /**//from  w ww .  j a v  a 2  s .  c om
     * Retrieves string 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