Intent的数据传递

发布时间:2020-07-08 18:29:17 作者:IT学无止境
来源:网络 阅读:443

虽然知识非常基础,但我觉得无论是否是难点,即便非常简单的知识,及时写出来对知识积累都是有好处的。今天写一下Intent的数据传递。

发送端:

//创建Intent
Intent intent = new Intent();

//把需要传递的内容放进Intent
intent.putExtra("id", waitInfo.id);
intent.putExtra("warnning_star", warnning_star);
intent.putExtra("fengxlx", waitInfo.fengxlx);
intent.putExtra("chehao", waitInfo.chehao);
intent.putExtra("content", waitInfo.content);
intent.putExtra("time", waitInfo.time);

//设置即将要启动的Activity
intent.setClass(getActivity(), ZaiTuYuJing_FengXCL_XiangXXX_Activity.class);

//跳转
startActivity(intent);

接收端:

//接收Intent
Intent intent = getIntent();

//取出捆绑数据
Bundle bundle = intent.getExtras();

//从数据中根据key取出所需内容
int index = Integer.parseInt(bundle.getString("id"));
String chehao = bundle.getString("chehao");
String content = bundle.getString("content");
String time = bundle.getString("time");


推荐阅读:
  1. intent使用
  2. Intent解析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

intent 数据传递 te nt

上一篇:nginx日志使用json输出

下一篇:oracle 函数之分析函数

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》