Puts int value to bundle bundle if passed and creates empty Bundle if null passed. - Android android.os

Android examples for android.os:Bundle

Description

Puts int value to bundle bundle if passed and creates empty Bundle if null passed.

Demo Code

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

public class Main{

    /**/*  www  .  j  ava  2  s. c om*/
     * Puts int value to bundle bundle if passed and creates it if {@code null} passed.
     *
     * @param bundle to put into
     * @param key    to to put under
     * @param value  to put
     * @return bundle with the newly put value
     */
    public static Bundle putInt(Bundle bundle, String key, int value) {
        if (bundle == null) {
            bundle = new Bundle();
        }
        bundle.putInt(key, value);
        return bundle;
    }

}

Related Tutorials