Puts int value to bundle bundle if passed and creates it if null passed. - Android Android OS

Android examples for Android OS:Bundle Put

Description

Puts int value to bundle bundle if passed and creates it if null passed.

Demo Code


//package com.book2s;
import android.os.Bundle;

public class Main {
    /**//from   w  ww  .  j  a va  2  s.c o m
     * 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