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

Android examples for Android OS:Bundle Get

Description

Retrieves float value from bundle if present.

Demo Code


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

public class Main {
    public static final float DEFAULT_FLOAT_VALUE = 0f;

    /**// www.java2 s  .c  om
     * Retrieves float value from bundle if present.
     *
     * @param bundle to get from
     * @param key    to search by
     * @return value or {@link #DEFAULT_FLOAT_VALUE} if nothing found
     */
    public static float getFloat(Bundle bundle, String key) {
        if (bundle != null && bundle.containsKey(key)) {
            return bundle.getFloat(key);
        } else {
            return DEFAULT_FLOAT_VALUE;
        }
    }
}

Related Tutorials