get Long from Bundle by key - Android Android OS

Android examples for Android OS:Bundle Key

Description

get Long from Bundle by key

Demo Code


//package com.book2s;

import android.os.Bundle;

public class Main {
    /**/* w w  w  . j a  va  2s. co m*/
     * get Long
     * @param bundle
     * @param key
     * @return
     */
    public static Long getLong(Bundle bundle, String key) {
        if (isEmpty(bundle, key)) {
            return null;
        } else {
            return bundle.getLong(key);
        }
    }

    /**
     * check whether a key is empty
     * @param bundle
     * @param key
     * @return
     */
    public static boolean isEmpty(Bundle bundle, String key) {
        return bundle == null || !bundle.containsKey(key);
    }
}

Related Tutorials