【转】intent.putextra的用法
来源:互联网 发布:ac68u对访客网络限速 编辑:程序博客网 时间:2024/05/16 00:37
在Android SDK的学习第一课中,提到这样的一段代码
Intent intent = new Intent(this, DisplayMessageActivity.class);EditText editText = (EditText) findViewById(R.id.edit_message);String message = editText.getText().toString();intent.putExtra(EXTRA_MESSAGE, message);解释如下:
转载地址:http://my.eoe.cn/xiangliang/archive/382.html
在Intent的构造函数中有两个参数:第一个参数是Context(上下文)一个是系统所需要传递的class对象。
而一个intent不仅允许你启动到另一个Activity,同时也可以传递数据包到另一个Activity里。
Sending an intent to other apps-发送intent(意图)到其他app(应用)
Intent(意图)可以传递各种各样的以键值对形式出现的集合,可以称它为extras,putExtra()方法用字符窜作为它的key,第二个参数作为它的值。为了在下一个Activity中获取extra(附加的)数据,你应该定义一个公共常量作为key(键),ok,在MyFirstActivity类的顶部定义一个名为EXTRA_MESSAGE的常量:
public class MyFirstActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myapp.MESSAGE";
...
}
将intent的extra用应用的包名作为前缀是一个很好的做法,可以保证在与其他APP交流时,这个extra是独一无二的。
0 0
- 【转】intent.putextra的用法
- Intent中putExtra()方法用法
- Intent中putExtra()方法用法
- intent.putExtra() 和 bundle.putExtra()的区别
- Android setArguments()和 Intent.putExtra()的用法之却别
- onActivityResult和putExtra的用法
- Bundle和Intent.putExtra的区别
- Intent 传递中 Bundle与intent.putExtra 的关系
- Intent 传递中 Bundle与intent.putExtra 的关系
- intent.putExtra()方法
- Intent putExtra getStringExtra
- intent putExtra 属性
- intent.putExtra()方法参数
- 再看Intent.putExtra
- intent与putextra
- intent.putExtra与intent.getStringExtra
- Android 中Intent的putExtra()方法的值传递
- Android开发中Intent类的putExtra和setData 区别
- java checkstyle检查问题
- 研究称施展“微笑魔法”可使人看起来更聪明
- activity详解
- libgdx 自适应分辨率
- 已打捞出一些物品并发现油迹
- 【转】intent.putextra的用法
- java UDP协议程序设计
- [Python]代码重复率查找工具Clone Digger
- 索引的优点和缺点
- 金正昆-商务礼仪-百家讲坛-重点笔记1
- C++: 为什么我们一般都要将函数的声明和定义分开?(separate the declaration of function from its definition)
- goldengate在aix上裸设备的数据库上配置extrct需要加参数RAWDEVICEOFFSET
- rapheal画箭头的方法
- DataInputStream 源码分析