码迷,mamicode.com
首页 > 移动开发 > 详细

android: Intent

时间:2015-09-17 19:45:16      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

使用Intent启动activity:

Intent intent = new Intent(MainActivity.this, OtherActivity.class);

startActivity(intent);

 

使用Intent启动其他app的activity:

Intent intent = new Intent();
intent.setClassName("com.example.project1","com.example.project1.MainActivity");
startActivity(intent);
com.example.project1是AndroidManifest.xml文件中的package值,
com.example.project1.MainActivity是目标Activity的完整类名。


Intent传值:
intent.putExtra("key", value);

Intent传类实例:
User user=new User("cc","lulu");
Bundle bundle=new Bundle();
bundle.putSerializable("obj", user);
intent.putExtra("obj", bundle);

User类必须实现Serializable接口。

android: Intent

标签:

原文地址:http://www.cnblogs.com/mada0/p/4817327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!