通过jsonarray从1活动到另一个活动jsonarray

2023-09-05 08:18:31 作者:你见爱情放过谁

我在做一个应用程序中,我想用传递一个JSON数组2之间的活动。如何通过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为字符串,然后将其连接到意向ANS发送。

Convert JsonArray to String then attach it to Intent ans 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");