While sending requests via Facebook_Android SDK, I get a bundle in return. Can someone explain what data type it is and how to extract the data in it? Thanks.
01-28 11:58:07.548: I/Values(16661): Bundle[{to[0]=100005099741441, to[1]=100005089509891, request=134129756751737}]
EDIT Here, to[i] is a string array. I was able to do it. but I don't think its the right way to do it.
for(int i=0;i< size-1;i++){
System.out.println(values.getString("to["+i+"]"));
}
where size
is the size of the Bundle called value
Here's how we get the object passed by a Bundle: Intent intent=getIntent(); // Instantiate a Bundle Bundle bundle=intent. getExtras(); //Get data inside Persion Persion persion= (Persion) bundle. getSerializable("persion"); text_show.
Android Bundle is used to pass data between activities. The values that are to be passed are mapped to String keys which are later used in the next activity to retrieve the values. Following are the major types that are passed/retrieved to/from a Bundle.
An Android App Bundle is a publishing format that includes all your app's compiled code and resources, and defers APK generation and signing to Google Play.
A Bundle
is basically a dictionary. Each value in the Bundle is stored under a key
. You must know the type of value under the key. When you know the type, you access the value associated with the key
by calling a method relevant for the type of the value (again, you must know the type).
For example if the key
is request
and its type is String
you would call:
String value = bundle.getString("request");
If the type was long
, you would call:
long value = bundle.getLong("request");
To loop over the to
array provided that the value is of type String
you can do this:
for (int i = 0; bundle.containsKey("to[" + i + "]"); i++) {
String toElement = bundle.getString("to[" + i + "]");
}
which does not rely on the size of the bundle object.
All the keys in a bundle and the type of value for each key should be provided in the Facebook API for Android. If you need further information on the Bundle
object please look at the reference here.
Bundle bundle = intent.getBundle();
bundle.getString("ITEM_NAME");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With