Used to get the parameter values passed into Activity via a Bundle. - Android Activity

Android examples for Activity:Activity Feature

Description

Used to get the parameter values passed into Activity via a Bundle.

Demo Code


//package com.java2s;
import android.app.Activity;

import android.os.Bundle;

public class Main {
    /**/*from   ww w .j a v a 2  s .c o  m*/
     * Used to get the parameter values passed into Activity via a Bundle.
     *
     * @param context The current Context or Activity that this method is called from
     * @param key     Extra key name.
     * @return param Parameter value
     */
    public static Object getExtraObject(Activity context, String key) {
        Object param = null;
        Bundle bundle = context.getIntent().getExtras();
        if (bundle != null) {
            param = bundle.get(key);
        }
        return param;
    }
}

Related Tutorials