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:ee.ioc.phon.android.speak.Utils.java

private static List<String> ppBundle(String bundleName, Bundle bundle) {
    List<String> strings = new ArrayList<String>();
    for (String key : bundle.keySet()) {
        Object value = bundle.get(key);
        String name = bundleName + key;
        if (value instanceof Bundle) {
            strings.addAll(ppBundle(name + "/", (Bundle) value));
        } else {//from  w  w w .ja  va 2 s. c  o m
            if (value instanceof Object[]) {
                strings.add(name + ": " + Arrays.toString((Object[]) value));
            } else if (value instanceof float[]) {
                strings.add(name + ": " + Arrays.toString((float[]) value));
            } else {
                strings.add(name + ": " + value);
            }
        }
    }
    return strings;
}

From source file:com.eyekabob.util.facebook.Util.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string/*from w ww  .j a va 2 s  . com*/
 * 
 * @param parameters the parameters need to be posted
 * @param boundary the random string as boundary
 * @return a string of the post body
 */
// COFFBR01 MODIFIED.
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {
        Object value = parameters.get(key);
        if (value instanceof byte[]) {
            continue;
        }

        sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + value);
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }

    return sb.toString();
}

From source file:org.fs.net.evoke.util.JsonUtility.java

/**
 *  /*from w w w . ja v  a 2 s.  c  om*/
 * @param bundle
 * @return
 */
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);
            }
            try {
                jsonObject.put(key, object);
            } catch (JSONException e) {
                if (isLogEnabled()) {
                    e.printStackTrace();
                }
            }
        }
    }
    return jsonObject;
}

From source file:com.turbulenz.turbulenz.googlepayment.java

static int getResponseCodeFromBundle(Bundle b) {
    Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        _log("response code is null, assuming OK"); // known issue
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer) {
        return ((Integer) o).intValue();
    } else if (o instanceof Long) {
        return (int) ((Long) o).longValue();
    } else {//from  ww w  . j av a  2s . c  o  m
        _error("!! Unexpected type for bundle response code." + o.getClass().getName());

        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.jameswolfeoliver.pigeon.Utilities.Utils.java

public static String bundleToString(Bundle bundle) {
    StringBuilder out = new StringBuilder("Bundle[");

    if (bundle == null) {
        out.append("null");
    } else {//w  w w .j a  v a  2  s  .com
        boolean first = true;
        for (String key : bundle.keySet()) {
            if (!first) {
                out.append(", ");
            }

            out.append(key).append('=');

            Object value = bundle.get(key);

            if (value instanceof int[]) {
                out.append(Arrays.toString((int[]) value));
            } else if (value instanceof byte[]) {
                out.append(Arrays.toString((byte[]) value));
            } else if (value instanceof boolean[]) {
                out.append(Arrays.toString((boolean[]) value));
            } else if (value instanceof short[]) {
                out.append(Arrays.toString((short[]) value));
            } else if (value instanceof long[]) {
                out.append(Arrays.toString((long[]) value));
            } else if (value instanceof float[]) {
                out.append(Arrays.toString((float[]) value));
            } else if (value instanceof double[]) {
                out.append(Arrays.toString((double[]) value));
            } else if (value instanceof String[]) {
                out.append(Arrays.toString((String[]) value));
            } else if (value instanceof CharSequence[]) {
                out.append(Arrays.toString((CharSequence[]) value));
            } else if (value instanceof Parcelable[]) {
                out.append(Arrays.toString((Parcelable[]) value));
            } else if (value instanceof Bundle) {
                out.append(bundleToString((Bundle) value));
            } else {
                out.append(value);
            }

            first = false;
        }
    }

    out.append("]");
    return out.toString();
}

From source file:barcamp.com.facebook.android.Util.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string/*from ww  w. j  ava  2s  . c o m*/
 * 
 * @param parameters the parameters need to be posted
 * @param boundary the random string as boundary
 * @return a string of the post body
 */
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {
        //if (parameters.getByteArray(key) != null) {
        if (parameters.get(key) instanceof byte[]) {
            continue;
        }

        sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameters.getString(key));
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }

    return sb.toString();
}

From source file:com.antew.redditinpictures.library.service.RESTService.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);

        // We can only put Strings in a form entity, so we call the toString()
        // method to enforce. We also probably don't need to check for null here
        // but we do anyway because Bundle.get() can return null.
        if (value != null) {
            formList.add(new BasicNameValuePair(key, value.toString()));
        }//www.j a  va2s .co m
    }

    return formList;
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public static Map<String, String> bundleToMap(Bundle bundle) {
    if (bundle == null) {
        return null;
    }/*from   w  w w.  j a v a  2s. c o  m*/
    Map<String, String> map = new HashMap<>();
    for (String e : bundle.keySet()) {
        map.put(e, (String) bundle.get(e));
    }
    return map;
}

From source file:karroo.app.test.facebook.Util.java

/**
 * Generate the multi-part post body providing the parameters and boundary
 * string//w  w  w.j  a  va2  s  .c o  m
 * 
 * @param parameters the parameters need to be posted
 * @param boundary the random string as boundary
 * @return a string of the post body
 */
public static String encodePostBody(Bundle parameters, String boundary) {
    if (parameters == null)
        return "";
    StringBuilder sb = new StringBuilder();

    for (String key : parameters.keySet()) {
        //            if (parameters.getByteArray(key) != null) {
        if (parameters.get(key) instanceof byte[]) {
            continue;
        }

        sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameters.getString(key));
        sb.append("\r\n" + "--" + boundary + "\r\n");
    }

    return sb.toString();
}

From source file:com.airbop.library.simple.CommonUtilities.java

static void displayMessageFromIntent(Context context, Intent intent) {
    if (intent != null) {
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            Set<String> keys = bundle.keySet();
            if (keys != null) {
                for (String key : keys) {
                    Object o = bundle.get(key);
                    if (o != null) {
                        displayMessage(context, "Key: " + key + " value: " + o);
                    }//from   www.j  a  va  2  s .  c  om
                }
            }
        } else {
            displayMessage(context, "Extras are null");
        }
    } else {
        displayMessage(context, "Intent is null");
    }
}