将 jsonarray 从 1 个活动传递到另一个活动 [英] passing jsonarray from 1 activity to another

查看:23
本文介绍了将 jsonarray 从 1 个活动传递到另一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,我想在其中在 2 个活动之间传递一个 json 数组.如何通过 android 中的意图将 json arry 从一个活动传递到另一个活动.有人可以帮我解决这个问题吗??谢谢

I am making an app in which I want o pass a json array between 2 activities .how to pass json arry from one activity to another through intents in android. can anybody help me over this?? thanks

推荐答案

您应该将 JsonArray 转换为 String 然后将其附加到 Intent 并发送.

You should convert JsonArray to String then attach it to Intent and send it.

JSONObject jObject = new JSONObject("Your Json Response");
Intent obj_intent = new Intent(Main.this, Main1.class);
Bundle b = new Bundle();                
b.putString("Array",jObject4.toString());
obj_intent.putExtras(b);

其中 jObject4 是 JSON 对象.

Where jObject4 is JSON Object.

进入下一页:

Bundle b = getIntent().getExtras();
String Array=b.getString("Array");

这篇关于将 jsonarray 从 1 个活动传递到另一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆