Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

In this page you can find the example usage for android.os Bundle get.

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T> T get(String key, Bundle bundle) {
    return (T) bundle.get(key);
}

From source file:Main.java

/**
 * 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./*from  ww w  .ja  v  a  2s  . co  m*/
 * @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;
}

From source file:Main.java

public static Object getParameter(Activity activity, String name) {
    Intent intent = activity.getIntent();
    if (intent == null)
        return null;

    Bundle bundle = intent.getExtras();
    if (bundle == null)
        return null;

    return bundle.get(name);
}

From source file:Main.java

public static void dumpIntent(Intent intent) {
    System.out.println("action: " + intent.getAction());
    System.out.println("data: " + intent.getData());
    System.out.println("extras:");
    Bundle bundle = intent.getExtras();
    for (String key : bundle.keySet()) {
        Object object = bundle.get(key);
        System.out.println(key + "->" + object + "(" + object.getClass().getName() + ")");
    }//from   ww  w.  j a va2  s  .c om
}

From source file:it.cosenonjaviste.mv2m.ArgumentManager.java

public static Object readArgument(Bundle arguments) {
    return arguments.get(ARGUMENT);
}

From source file:Main.java

public static String bundle2string(Bundle bundle) {
    String string = "{";
    for (String key : bundle.keySet()) {
        string += " " + key + " => " + bundle.get(key) + ";";
    }//from ww w .j a  v a 2 s  .c  o m
    string += " }";
    return string;
}

From source file:Main.java

public static void dumpBatteryStats(Context context) {
    IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent batteryStatus = context.registerReceiver(null, ifilter);

    Bundle bundle = batteryStatus.getExtras();
    for (String key : bundle.keySet()) {
        Object value = bundle.get(key);
        Log.d(TAG, String.format("Battery,%s=%s (%s)", key, value.toString(), value.getClass().getName()));
    }/*from ww w .  j  a  va  2  s .  co  m*/
}

From source file:Main.java

public static ApplicationInfo findMetaData(Context ctx, String key) {
    PackageManager pm = ctx.getPackageManager();
    try {// w w  w. j  av  a2s .c  o  m
        List<PackageInfo> pkgList = pm.getInstalledPackages(0);
        for (PackageInfo info : pkgList) {
            ApplicationInfo appInfo = pm.getApplicationInfo(info.packageName, PackageManager.GET_META_DATA);
            Bundle bd = appInfo.metaData;
            if (bd == null)
                continue;
            Object obj = bd.get(key);
            if (obj != null) {
                //                    System.out.println("find it , panme : "+appInfo.packageName);
                return appInfo;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static void LogBundleExtras(Bundle bundle) {
    for (String key : bundle.keySet()) {
        Object value = bundle.get(key);

        StringBuilder builder = new StringBuilder();
        builder.append("key: ");
        builder.append(key);//  w w  w  .ja v  a  2 s .c o  m
        builder.append("\t\t\t\t");

        if (value != null) {

            builder.append("key: ");
            builder.append(key);
            builder.append("\t\t\t\t");

            if (value instanceof CharSequence[]) {
                builder.append("\n====== Charsequense[]======\n");

                for (CharSequence seq : bundle.getCharSequenceArray(key)) {
                    builder.append("value(charseq): ");
                    builder.append(seq);
                    builder.append("\n");
                }
                builder.append("====== \"Charsequense[]======\n");
            } else {
                builder.append("value: ");
                builder.append(value);
                builder.append("\t");
            }

            builder.append("value class: ");
            builder.append(value.getClass().getName());
        } else

            builder.append("value: null");

        Log.d(TAG, builder.toString());
    }
}

From source file:Main.java

public static Object getBundleArg(Bundle extras, String argumentKey) {
    if (extras == null) {
        return null;
    }//from  w  w w .j a  v a 2s.c o m
    if (!extras.containsKey(argumentKey))
        return null;
    return extras.get(argumentKey);

}