Retrieves java.util.ArrayList of strings from bundle if present. - Android android.os

Android examples for android.os:Bundle

Description

Retrieves java.util.ArrayList of strings from bundle if present.

Demo Code

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

public class Main{

    /**/*from www.  ja  v  a 2s  . c o  m*/
     * Retrieves {@link java.util.ArrayList} of strings from bundle if present.
     *
     * @param bundle to get from
     * @param key    to search by
     * @return value or empty {@link java.util.ArrayList} if nothing found
     */
    public static ArrayList<String> getArrayList(Bundle bundle, String key) {
        if (bundle != null && bundle.containsKey(key)) {
            return bundle.getStringArrayList(key);
        } else {
            return new ArrayList<String>();
        }
    }

}

Related Tutorials