如何通过JSON对象为新活动 [英] How to pass JSON Object to new activity

查看:118
本文介绍了如何通过JSON对象为新活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要使用的AsyncTask从以下网址下载JSON,并在onPostExecute()传递一个JSON对象到下一个活动使用putExtra方法,但IAM不断得到一个错误的辩论,因为putExtra是只传递字符串不是一个对象,可以即以某种方式固定?

I have application that needs to download JSON from URL using AsyncTask , and on onPostExecute() pass that JSON Object to next Activity using putExtra method , but iam constantly getting an error ,cuz putExtra is passing only strings not an Objects , can that be fixed somehow?

推荐答案

传递参数时,做到这一点:

Do this when passing the param:

intent.putExtra("json", jsonobj.toString());

而在你的新活动分析它,像这样:

And in your new activity parse it like so:

JSONObject obj = new JSONObject(getIntent().getStringExtra("json"));

这篇关于如何通过JSON对象为新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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