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:com.normalexception.app.rx8club.fragment.FragmentUtils.java

/**
 * Dump arguments that were passed into a fragment for debug purposes
 * @param args   Fragment argument bundle
 *//*from w w w  .  ja  v a  2 s. co m*/
public static void dumpArgs(Bundle args) {
    Set<String> k_args = args.keySet();
    Log.d(TAG, "> Dumping Fragment Arguments");
    for (String key : k_args) {
        Log.d(TAG, String.format("%s = %s", key, args.get(key)));
    }
    Log.d(TAG, "> End Dump");
}

From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java

private static List<BasicNameValuePair> paramsToList(Bundle params) {
    ArrayList<BasicNameValuePair> formList = new ArrayList<BasicNameValuePair>(params.size());

    for (String key : params.keySet()) {
        Object value = params.get(key);

        if (value != null)
            formList.add(new BasicNameValuePair(key, value.toString()));
    }//w  w  w.  j a v  a2 s .  c o m

    return formList;
}

From source file:bolts.MeasurementEvent.java

/**
 *  Broadcast Bolts measurement event./*from www  .  j a  va2 s .  c  o m*/
 *  Bolts raises events to the application with this method by sending
 *  {@link #MEASUREMENT_EVENT_NOTIFICATION_NAME} broadcast.
 *
 *  @param context the context of activity or application who is going to send the event. required.
 *  @param name the event name that is going to be sent. required.
 *  @param intent the intent that carries the logging data in its extra bundle and data url. optional.
 *  @param extraLoggingData other logging data to be sent in events argument. optional.
 *
 */
static void sendBroadcastEvent(Context context, String name, Intent intent,
        Map<String, String> extraLoggingData) {
    Bundle logData = new Bundle();
    if (intent != null) {
        Bundle applinkData = AppLinks.getAppLinkData(intent);
        if (applinkData != null) {
            logData = getApplinkLogData(context, name, applinkData, intent);
        } else {
            Uri intentUri = intent.getData();
            if (intentUri != null) {
                logData.putString("intentData", intentUri.toString());
            }
            Bundle intentExtras = intent.getExtras();
            if (intentExtras != null) {
                for (String key : intentExtras.keySet()) {
                    Object o = intentExtras.get(key);
                    String logValue = objectToJSONString(o);
                    logData.putString(key, logValue);
                }
            }
        }
    }

    if (extraLoggingData != null) {
        for (String key : extraLoggingData.keySet()) {
            logData.putString(key, extraLoggingData.get(key));
        }
    }
    MeasurementEvent event = new MeasurementEvent(context, name, logData);
    event.sendBroadcast();
}

From source file:org.getlantern.firetweet.util.CompareUtils.java

public static boolean bundleEquals(final Bundle bundle1, final Bundle bundle2, final String... ignoredKeys) {
    if (bundle1 == null || bundle2 == null)
        return bundle1 == bundle2;
    final Iterator<String> keys = bundle1.keySet().iterator();
    while (keys.hasNext()) {
        final String key = keys.next();
        if (!ArrayUtils.contains(ignoredKeys, key) && !objectEquals(bundle1.get(key), bundle2.get(key)))
            return false;
    }/*from www  . j a v  a 2  s . c  om*/
    return true;
}

From source file:com.arellomobile.android.push.PushGCMIntentService.java

private static void generateNotification(Context context, Intent intent, Handler handler) {
    Bundle extras = intent.getExtras();
    if (extras == null) {
        return;/*  www .  j  a v  a  2  s. co  m*/
    }

    extras.putBoolean("foregroud", GeneralUtils.isAppOnForeground(context));

    String title = (String) extras.get("title");
    String link = (String) extras.get("l");

    // empty message with no data
    Intent notifyIntent;
    if (link != null) {
        // we want main app class to be launched
        notifyIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
        notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    } else {
        notifyIntent = new Intent(context, PushHandlerActivity.class);
        notifyIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);

        // pass all bundle
        notifyIntent.putExtra("pushBundle", extras);
    }

    // first string will appear on the status bar once when message is added
    CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo());
    if (null == appName) {
        appName = "";
    }

    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    NotificationFactory notificationFactory;

    //is this banner notification?
    String bannerUrl = (String) extras.get("b");

    //also check that notification layout has been placed in layout folder
    int layoutId = context.getResources().getIdentifier(BannerNotificationFactory.sNotificationLayout, "layout",
            context.getPackageName());

    if (layoutId != 0 && bannerUrl != null) {
        notificationFactory = new BannerNotificationFactory(context, extras, appName.toString(), title,
                PushManager.sSoundType, PushManager.sVibrateType);
    } else {
        notificationFactory = new SimpleNotificationFactory(context, extras, appName.toString(), title,
                PushManager.sSoundType, PushManager.sVibrateType);
    }
    notificationFactory.generateNotification();
    notificationFactory.addSoundAndVibrate();
    notificationFactory.addCancel();

    Notification notification = notificationFactory.getNotification();

    notification.contentIntent = PendingIntent.getActivity(context, 0, notifyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    if (mSimpleNotification) {
        manager.notify(PushManager.MESSAGE_ID, notification);
    } else {
        manager.notify(PushManager.MESSAGE_ID++, notification);
    }

    generateBroadcast(context, extras);
}

From source file:Main.java

public static String printBundle(Bundle bundle) {
    StringBuilder sb = new StringBuilder();
    sb.append("Bundle: ");
    if (bundle != null) {
        sb.append(bundle.toString());//from   ww  w . j  a  v a2s .  c o  m
        sb.append("\n");
        Set<String> keys = bundle.keySet();
        for (String it : keys) {
            sb.append("   ");
            sb.append(it);
            sb.append(": ");
            sb.append(bundle.get(it).toString());
            sb.append("\n");
        }
    } else {
        sb.append("(null)");
    }
    return sb.toString();
}

From source file:com.googlecode.android_scripting.jsonrpc.JsonBuilder.java

private static JSONObject buildJsonBundle(Bundle bundle) throws JSONException {
    JSONObject result = new JSONObject();
    for (String key : bundle.keySet()) {
        result.put(key, build(bundle.get(key)));
    }/*w  ww .  jav a  2s  .  c o  m*/
    return result;
}

From source file:com.github.michalbednarski.intentslab.Utils.java

public static <T> T getLiveRefFromBundle(Bundle bundle, String key) {
    final Object binder = bundle.get(key);
    if (binder instanceof LiveRefInBundle) {
        return (T) ((LiveRefInBundle) binder).target;
    }/*from  www.j  a  v a  2 s  .  c  om*/
    return null;
}

From source file:crow.util.Util.java

/**
 * ? meta   <code>// www.  ja va 2  s .  c  om
 * <meta-data android:name="keyName"
 * android:value="0123456789abc" />
 * </code>
 * 
 * @param context
 * @param keyName
 *            name of meta-data
 * @return value of meta-data null ?
 */
public static String readMetaByKey(Context context, String keyName) {
    try {
        ApplicationInfo appi = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                PackageManager.GET_META_DATA);
        Bundle bundle = appi.metaData;
        return (String) bundle.get(keyName);
    } catch (Exception e) {
        return null;
    }
}

From source file:org.fs.ghanaian.util.JsonUtility.java

public static JSONObject parseObject(Bundle bundle) {
    JSONObject jsonObject = new JSONObject();

    if (bundle != null) {
        Set<String> keys = bundle.keySet();
        for (String key : keys) {
            Object object = bundle.get(key);

            if (object instanceof Bundle) {
                object = parseObject((Bundle) object);
            }/*from  w w  w .  ja  va2s.c o m*/

            try {
                jsonObject.put(key, object);
            } catch (JSONException e) {
                if (isLogEnabled()) {
                    e.printStackTrace();
                }
            }
        }
    }

    return jsonObject;
}