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

Android examples for android.os:Bundle

Description

Retrieves float value from bundle if present

Demo Code

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

public class Main{

    public static final float DEFAULT_FLOAT_VALUE = 0f;
    /**/*from  ww  w  .  ja va 2 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