您的位置:首页 > 其它

activity 之间值传递

2016-06-11 11:55 183 查看

【推荐阅读】微服务还能火多久?>>>

如何在activity之间传递对象

 

  • 传递端
Intent intent = new Intent();
intent.setClass(Login.this, MainActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("user", user);
intent.putExtras(bundle);
this.startActivity(intent);
  • 接收端
Intent intent = this.getIntent();
user=(User)intent.getSerializableExtra("user");

 

  • 将传递的类对象继承序列化

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: