List of usage examples for android.os Bundle keySet
public Set<String> keySet()
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 */// ww w . ja v a 2 s . c om 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:org.mariotaku.twidere.extension.mediauploader.util.ParseUtils.java
public static String bundleToJSON(final Bundle args) { final Set<String> keys = args.keySet(); final JSONObject json = new JSONObject(); for (final String key : keys) { final Object value = args.get(key); if (value == null) { continue; }//from w w w .java2 s. c o m try { if (value instanceof Boolean) { json.put(key, args.getBoolean(key)); } else if (value instanceof Integer) { json.put(key, args.getInt(key)); } else if (value instanceof Long) { json.put(key, args.getLong(key)); } else if (value instanceof String) { json.put(key, args.getString(key)); } else { Log.w(LOGTAG, "Unknown type " + value.getClass().getSimpleName() + " in arguments key " + key); } } catch (final JSONException e) { e.printStackTrace(); } } return json.toString(); }
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 ww w . j a v a 2 s . c om return true; }
From source file:org.magdaaproject.utils.serval.RhizomeUtils.java
/** * convert a Rhizome bundle into a JSON representation * /* w w w . j a va 2 s. c o m*/ * @param bundle the bundle to convert * @return the bundle contents as JSON */ public static String bundleToJson(Bundle bundle) { JSONObject mObject = new JSONObject(); Set<String> mBundleKeys = bundle.keySet(); for (String mKey : mBundleKeys) { try { mObject.put(mKey, bundle.get(mKey).toString()); } catch (JSONException e) { Log.e(sLogTag, "unable to add Rhizome bundle element to JSON object", e); } } return mObject.toString(); }
From source file:com.geekandroid.sdk.sample.JPushReceiver.java
private static String printBundle(Bundle bundle) { StringBuilder sb = new StringBuilder(); for (String key : bundle.keySet()) { if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) { sb.append("\nkey:" + key + ", value:" + bundle.getInt(key)); } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) { sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key)); } else if (key.equals(JPushInterface.EXTRA_EXTRA)) { if (bundle.getString(JPushInterface.EXTRA_EXTRA).isEmpty()) { Log.i(TAG, "This message has no Extra data"); continue; }/* ww w . j av a2 s . c om*/ try { JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA)); Iterator<String> it = json.keys(); while (it.hasNext()) { String myKey = it.next().toString(); sb.append("\nkey:" + key + ", value: [" + myKey + " - " + json.optString(myKey) + "]"); } } catch (JSONException e) { Log.e(TAG, "Get message extra JSON error!"); } } else { sb.append("\nkey:" + key + ", value:" + bundle.getString(key)); } } return sb.toString(); }
From source file:com.fanfou.app.opensource.util.IntentHelper.java
public static void logIntent(final String tag, final Intent intent) { if (intent == null) { return;/* w w w. j a va 2 s .co m*/ } final StringBuffer sb = new StringBuffer(); sb.append("\nAction:" + intent.getAction()); sb.append("\nData:" + intent.getData()); sb.append("\nDataStr:" + intent.getDataString()); sb.append("\nScheme:" + intent.getScheme()); sb.append("\nType:" + intent.getType()); final Bundle extras = intent.getExtras(); if ((extras != null) && !extras.isEmpty()) { for (final String key : extras.keySet()) { final Object value = extras.get(key); sb.append("\nEXTRA: {" + key + "::" + value + "}"); } } else { sb.append("\nNO EXTRAS"); } Log.i(tag, sb.toString()); }
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 w ww . jav a 2s .com*/ 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.onesignal.NotificationBundleProcessor.java
public static JSONObject bundleAsJSONObject(Bundle bundle) { JSONObject json = new JSONObject(); Set<String> keys = bundle.keySet(); for (String key : keys) { try {//from w w w. j a v a2 s.c om json.put(key, bundle.get(key)); } catch (JSONException e) { } } return json; }
From source file:Main.java
public static void registerNewSourceSinkConnection(int counter, Bundle bundle) { Log.i("PEP", "in registerNewSourceSinkConnection(int counter, Bundle bundle)"); int taintInfoKeyCounter = 0; if (bundle != null) { for (String intentKey : bundle.keySet()) { if (intentKey.startsWith(keyBaseName)) { String possibleNumber = intentKey.substring(keyBaseName.length()); if (possibleNumber.length() > 0 && TextUtils.isDigitsOnly(possibleNumber)) { int currentCounter = Integer.parseInt(possibleNumber); if (taintInfoKeyCounter < currentCounter) taintInfoKeyCounter = currentCounter; }//from ww w.j av a2 s. co m } } if (taintInfoKeyCounter == 0) { Log.i("PEP", "bundle:" + bundle.toString()); if (bundle.containsKey(keyBaseName)) { String taintSourceCats = bundle.getString(keyBaseName); String[] allCats = taintSourceCats.split(","); sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats))); } } else { if (bundle.containsKey(keyBaseName + taintInfoKeyCounter)) { String taintSourceCats = bundle.getString(keyBaseName + taintInfoKeyCounter); String[] allCats = taintSourceCats.split(","); sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats))); } } } }
From source file:at.wada811.utils.DumpUtils.java
public static String toString(Bundle bundle) { if (bundle == null) { return "null"; }// w w w . ja v a2s.co m JSONObject json = new JSONObject(); for (String key : bundle.keySet()) { try { Object value = bundle.get(key); json.put(key, DumpUtils.toString(value)); } catch (JSONException e) { e.printStackTrace(); } } return json.toString(); }