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

Android examples for android.os:Bundle

Description

Retrieves int value from bundle if present

Demo Code

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

public class Main{

    public static final int DEFAULT_INT_VALUE = 0;
    /**/*from   w w w  .  j a va2  s  . co  m*/
     * Retrieves int value from bundle if present.
     *
     * @param bundle to get from
     * @param key    to search by
     * @return value or {@link #DEFAULT_INT_VALUE} if nothing found
     */
    public static int getInt(Bundle bundle, String key) {
        if (bundle != null && bundle.containsKey(key)) {
            return bundle.getInt(key);
        } else {
            return DEFAULT_INT_VALUE;
        }
    }

}

Related Tutorials