Android examples for android.os:Bundle
get Double value from Bundle with or without default value
import android.os.Bundle; import android.text.TextUtils; public class Main { public static double getDouble(Bundle bundle, String key) { return getDouble(bundle, key, 0.0); }//from ww w . j av a2s .co m public static double getDouble(Bundle bundle, String key, double df) { return getValue(bundle, key, df); } @SuppressWarnings("unchecked") public static <T> T getValue(Bundle bundle, String key, T df) { if (bundle == null || TextUtils.isEmpty(key)) { return df; } if (df == null) { return df; } if (!bundle.containsKey(key)) { return df; } T value = df; Object obj = bundle.get(key); if (obj != null && value.getClass().isAssignableFrom(obj.getClass())) { value = (T) obj; } return value; } }