List or print all "Extras" from intent or Bundle
This snippet is for listing all "Extras" from intent or any data stored in a bundle
Android class Bundle is a widely used class for passing data between several activities.
In many times, yo are faced to a bundle and you don't know what information it contains, so listing all the key-value pairs inside the content of the bundle could be really handy
Here is the android code you can use to list the data contained in the bundle. enjoy it and make any comment
XML code:
JAVA code:
StringBuilder builder = new StringBuilder("Extras:\n"); for (String key : extras.keySet()) { //extras is the Bundle containing info Object value = extras.get(key); //get the current object builder.append(key).append(": ").append(value).append("\n"); //add the key-value pair to the } Log.i("Extras",builder.toString()); //log the data or use it as needed.