Ana Ana - 1 year ago 79
JSON Question

Pass two bundles to same activity

I have a list of json array response with multiple userinformation. Created a bundle and successfully passed it to next activity. Created another bundle with user selected date and time.But no luck to second bundle to the same activity because i can be able to pass only one bundle to same activity.

My actual problem is how to pass second bundle in putExtras to same activity

Json Response
"userinfo": [
"address": "Tambaram",
"name": "Vishranthi"
"address": "Medavakkam",
"name": "Sophia"

Bundle creation code:

JSONArray infoarray = obj.getJSONArray("Info");
Bundle h = new Bundle();
for (int i = 0; i < infoarray.length(); i++) {
Bundle b = new Bundle();

JSONObject infoobject = infoarray.getJSONObject(i);
String name = infoobject.getString("name");
String address = infoobject.getString("address");

b.putString("name", name);
b.putString("address", address);

h.putBundle(Integer.toString(i), b);

Intent i = new Intent(context, Secondpage.class);
Bundle d=new Bundle();
d.putString("date", text1);
d.putString("time", text2);


Answer Source

if you want to put two bundles into your intent you have to use

Intent putExtra (String name, 
                Bundle value)

something like this:

Intent i = new Intent(context, Secondpage.class);
i.putExtra("bundleH", h);
i.putExtra("bundleD", d);


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download