gpt4 book ai didi

android - 我如何将 HTTP 响应从一个 Activity 传递到 android 中的另一个 Activity

转载 作者:行者123 更新时间:2023-11-29 17:44:48 26 4
gpt4 key购买 nike

在我的应用程序中,每当我发出 HTTP 帖子时,它都会以 JSON 形式提供 HTTP 响应。但我想在另一个 Activity 中解析这个 json。那么我们如何将 HTTP 响应从一个 Activity 传递到 android 中的另一个 Activity 。

最佳答案

Intent i =new Intent(CurrentActivity.this,NewActivity.class);

i.putExtra("json", jsonobject.toString());

startActivity(i);

在新的 Activity 中你可以像这样获取你的 json 数据

Intent intent = getIntent();

if (intent != null) {

String json = intent.getStringExtra("json");
JSONObject jsonObj = new JSONObject(json);

}

关于android - 我如何将 HTTP 响应从一个 Activity 传递到 android 中的另一个 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27419146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com