get the parameter values passed into Activity via a Bundle - Android android.app

Android examples for android.app:Activity Property

Description

get the parameter values passed into Activity via a Bundle

Demo Code

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import java.util.Map;
import java.util.Map;

public class Main{

    /**/*from w  w  w.  j  a v  a 2s.  com*/
     * 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