Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I know what data is given in a Bundle?

I'm having a heck of a time figuring out what data is coming to my methods through Intent/Bundles. I've tried adding break points to inspect the data, but I don't see anything. Perhaps because it's a Parcelable I can't manually read it in Eclipse.

For instance, a onActivityResult(int requestCode, int resultCode, Intent data) for a Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI). How do I know what data is available? Notice, I'm not ask for WHAT data is available but how the heck do I figure it out so I can apply the same idea to any Bundle/Intent from the Android framework? Perhaps it's a simple as looking at the docs, but I don't see a full listing of the data and I can't see it in Eclipse. So I'm at a lost.

like image 481
user123321 Avatar asked Jun 24 '11 23:06

user123321


People also ask

What is the best definition for Bundle Android?

Bundle is used to pass data between Activities. You can create a bundle, pass it to Intent that starts the activity which then can be used from the destination activity.

What is bundle Kotlin?

Bundles are generally used for passing data between various Android activities. It depends on you what type of values you want to pass, but bundles can hold all types of values and pass them to the new activity.


2 Answers

Bundle.keySet() gives you a list of all keys in the bundle. That said, typically you just expect certain keys and query them, but keySet() is used to examine bundles you get from somewhere.

like image 135
EboMike Avatar answered Sep 29 '22 20:09

EboMike


public static String bundle2string(Bundle bundle) {     if (bundle == null) {         return null;     }     String string = "Bundle{";     for (String key : bundle.keySet()) {         string += " " + key + " => " + bundle.get(key) + ";";     }     string += " }Bundle";     return string; } 
like image 26
18446744073709551615 Avatar answered Sep 29 '22 20:09

18446744073709551615