List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:com.groupme.sdk.util.HttpUtils.java
public static String encodeParams(Bundle params) { if (params == null || params.isEmpty()) { return ""; }/* w w w . j a v a 2 s .c om*/ StringBuilder sb = new StringBuilder(); boolean first = true; for (String key : params.keySet()) { if (first) { first = false; } else { sb.append("&"); } try { sb.append(URLEncoder.encode(key, Constants.UTF_8)).append("=") .append(URLEncoder.encode(params.getString(key), Constants.UTF_8)); } catch (UnsupportedEncodingException e) { Log.e(Constants.LOG_TAG, "Unsupported encoding: " + e.toString()); } } return sb.toString(); }
From source file:br.com.ufc.palestrasufc.twitter.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string/*from w w w . j a v a 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) { 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:org.fs.net.evoke.util.JsonUtility.java
/** * //from w w w . j a va2 s .c o m * @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:fb.android.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string/*w w w . j a v a 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 */ 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; } 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:barcamp.com.facebook.android.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string//from w w w . j a v a 2 s.co 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:karroo.app.test.facebook.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string//w ww .j a va 2s . com * * @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:Main.java
/** * Compares two {@link android.os.Bundle Bundles} to check for equality. * * @param a the first {@link android.os.Bundle Bundle} * @param b the second {@link android.os.Bundle Bundle} * @return {@code true} if the two {@link android.os.Bundle Bundles} have identical contents, or are both null *//* w ww .j a v a2 s . co m*/ public static boolean areEqual(@Nullable Bundle a, @Nullable Bundle b) { // equal if both null if (a == null && b == null) return true; // unequal if one is null if (a == null || b == null) return false; // check size if (a.size() != b.size()) return false; // get key sets Set<String> bundleAKeys = a.keySet(); Object valueA; Object valueB; // loop keys for (String key : bundleAKeys) { // check key exists in second bundle if (!b.containsKey(key)) return false; // get values valueA = a.get(key); valueB = b.get(key); // check null valued entries if (valueA == null && valueB == null) continue; if (valueA == null || valueB == null) return false; // compare iteratively if they are both bundles if (valueA instanceof Bundle && valueB instanceof Bundle) { if (!areEqual((Bundle) valueA, (Bundle) valueB)) return false; continue; } // check for different values if (!valueA.equals(valueB)) return false; } // passed! return true; }
From source file:at.wada811.utils.IntentUtils.java
public static String dump(Intent intent) throws JSONException { JSONObject json = new JSONObject(); json.put("action", intent.getAction()); if (intent.getCategories() != null) { JSONArray categories = new JSONArray(); for (String category : intent.getCategories()) { categories.put(category);//from w w w.ja v a2 s . c o m } json.put("category", categories); } json.put("type", intent.getType()); Bundle bundle = intent.getExtras(); if (bundle != null) { JSONObject extras = new JSONObject(); for (String key : bundle.keySet()) { extras.put(key, bundle.get(key)); } json.put("extras", extras); } return json.toString(4); }
From source file:com.facebook.android.Util.java
/** * Generate the multi-part post body providing the parameters and boundary * string//ww w. j a v a 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 */ @Deprecated public static String encodePostBody(Bundle parameters, String boundary) { if (parameters == null) return ""; StringBuilder sb = new StringBuilder(); for (String key : parameters.keySet()) { Object parameter = parameters.get(key); if (!(parameter instanceof String)) { continue; } sb.append("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n" + parameter); sb.append("\r\n" + "--" + boundary + "\r\n"); } return sb.toString(); }
From source file:org.linkdroid.PostJob.java
private static final String calculateBundleExtrasHmac(Bundle data, String secretString) throws NoSuchAlgorithmException, IOException, InvalidKeyException { Mac mac = initHmacSha1(secretString, null); SortedSet<String> keys = new TreeSet<String>(data.keySet()); for (String key : keys) { mac.update(key.getBytes(UTF8));/*from w w w. jav a 2s.c o m*/ Object value = data.get(key); // We only add the value to the hmac digest if it exists; the key is still // part of the digest calculation. if (value != null) { mac.update(value.toString().getBytes(UTF8)); } } return hmacDigestToHexString(mac.doFinal()); }