Skip to content

Instantly share code, notes, and snippets.

@TechIsFun
Created January 7, 2015 15:42
Show Gist options
  • Select an option

  • Save TechIsFun/cc724e33bceb123bd27a to your computer and use it in GitHub Desktop.

Select an option

Save TechIsFun/cc724e33bceb123bd27a to your computer and use it in GitHub Desktop.
Dump content of bundle to a String
public static String bundle2String(Bundle bundle) {
StringBuilder sb = new StringBuilder();
List<String> keys = new ArrayList<String>(bundle.keySet());
Collections.sort(keys);
for (String key : keys) {
Object value = bundle.get(key);
if (value == null) {
sb.append(String.format("%s: null", key));
} else {
sb.append(String.format("%s: %s (%s)", key, value.toString(), value.getClass().getName()));
}
sb.append("\n");
}
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment