List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:Main.java
public static void appendBundleAsUrlArgs(StringBuilder builder, Bundle properties) { if (builder == null) { return;//from ww w. j av a2s .co m } Object[] keySetIds = properties.keySet().toArray(); for (int i = 0; i < keySetIds.length; i++) { String key = (String) keySetIds[i]; if (properties.get(key) == null) { continue; } appendPropertyAsUrlArgs(builder, key, properties.get(key).toString()); if (i < keySetIds.length - 1) builder.append(URL_AND); } }
From source file:Main.java
public static Map<String, String> bundleToMap(Bundle bundle) { if (bundle == null) return null; Map<String, String> map = new HashMap<String, String>(); for (String key : bundle.keySet()) { map.put(key, bundle.get(key).toString()); }/*w ww. j a v a 2 s . c om*/ return map; }
From source file:com.deltadna.android.sdk.notifications.Utils.java
static String convert(Bundle payload) { final JSONObject result = new JSONObject(); for (final String key : payload.keySet()) { try {//ww w . j a v a 2s . c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { result.put(key, payload.get(key)); } else { result.put(key, JSONObject.wrap(payload.get(key))); } } catch (JSONException e) { Log.w(BuildConfig.LOG_TAG, e); } } return result.toString(); }
From source file:Main.java
public static <T> Map<String, T> fromBundle(Bundle input, Class<T> claz) { input.setClassLoader(claz.getClassLoader()); Map<String, T> output = new ArrayMap<String, T>(); for (String key : input.keySet()) { output.put(key, (T) input.get(key)); }/* w w w . ja v a2 s. c om*/ return output; }
From source file:Main.java
public static JSONObject toJSON(Bundle object) { JSONObject jsonObject = new JSONObject(); for (String key : object.keySet()) { try {//w w w . java2 s .c om jsonObject.put(key, object.get(key)); } catch (JSONException je) { } } return jsonObject; }
From source file:Main.java
/** * Returns GET url with appended parameters. * * @param url//w ww . j a v a 2 s. com * @param params * @return */ public static String toGetUrl(String url, Bundle params) { if (params != null) { if (!url.endsWith("?")) { url = url + "?"; } for (String key : params.keySet()) { url = url + key + "=" + params.getString(key) + "&"; } } return url; }
From source file:Main.java
/** * Convert bundle to readable string/* w ww . j av a2 s .c o m*/ * * @param bundle The bundle to convert * @return String representation of bundle */ public static String toString(Bundle bundle) { if (bundle == null) { return null; } StringBuilder stringBuilder = new StringBuilder(); for (String key : bundle.keySet()) { Object value = bundle.get(key); stringBuilder.append( String.format("%s %s (%s)\n", key, value, value == null ? "null" : value.getClass().getName())); } return stringBuilder.substring(0, stringBuilder.length() - 1); }
From source file:Main.java
public static String encodePostParams(Bundle params) { StringBuilder sb = new StringBuilder(); boolean and = true; for (String key : params.keySet()) { if (!and) { sb.append("&"); }// ww w .j a v a2s. c om sb.append(key + "=" + params.getString(key)); and = false; } return sb.toString(); }
From source file:Main.java
public static void printExtras(Intent i) { if (i == null) { return;/* w w w .j av a 2s .c om*/ } Bundle bundle = i.getExtras(); if (bundle == null) { return; } Log.d("INTENT_EXTRAS", "++++ Printing extras: +++"); for (String key : bundle.keySet()) { Object value = bundle.get(key); Log.d("INTENT_EXTRAS", String.format("%s %s (%s)", key, value.toString(), value.getClass().getName())); } }
From source file:Main.java
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) { continue; }/*from w ww.ja va 2 s. c om*/ 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(); }