intercept Int Param from Bundle - Android android.os

Android examples for android.os:Bundle

Description

intercept Int Param from Bundle

Demo Code

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;

public class Main{

    public static int interceptIntParam(Bundle savedInstanceState,
            Intent intent, String paramName) {
        int ret = -1;

        if (savedInstanceState != null) {
            ret = savedInstanceState.getInt(paramName, -1);
        } else {/*  www . j a v  a  2s  . c  o m*/
            if (intent != null) {
                Bundle incomming = intent.getExtras();
                if (incomming != null) {
                    ret = incomming.getInt(paramName, -1);
                }
            }
        }

        return ret;
    }

}

Related Tutorials