Intent之Component
来源:互联网 发布:得熊猫者得天下知乎 编辑:程序博客网 时间:2024/05/22 03:42
1、Intent的概念:
Android中提供了Intent机制来协助应用间的交互与通讯,或者采用更准确的说法是,Intent不仅可用于应用程序之间,也可用于应用程序内部的activity, service和broadcast receiver之间的交互。Intent这个英语单词的本意是“目的、意向、意图”。
Intent是一种运行时绑定(runtime binding)机制,它能在程序运行的过程中连接两个不同的组件。通过Intent,你的程序可以向Android表达某种请求或者意愿,Android会根据意愿的内容选择适当的组件来响应。
二、Intent的相关属性:
Intent由以下各个组成部分:
component(组件):目的组件
action(动作):用来表现意图的行动
category(类别):用来表现动作的类别
data(数据):表示与动作要操纵的数据
type(数据类型):对于data范例的描写
extras(扩展信息):扩展信息
Flags(标志位):期望这个意图的运行模式
三、Component
Intent的Component属性需要接受一个ComponentName对象。
Intent包含如下三个方法。
setClass(Context packageContext,Class
//定义ComponentNameComponentName componentName=new ComponentName(EditTextActivity.this,ShowPictureActivity.class);//表示登录成功,请跳入另一个界面Intent intent = new Intent(); //intent相当于一个快递员//设置intent要携带的内容,就是用户名intent.putExtra("name", userName); //第一个参数是关键字key, 第二个参数是携带的字符串数据 intent.setComponent(componentName); //启动新的界面 startActivity(intent);
在另一个Activity中
//获取用户名,从跳转的Intent中获取Intent intent = getIntent();//参数是关键字key,与intent.putExtra("name", userName)中第一个参数相同String userName =intent.getStringExtra("name");
0 0
- Intent之Component
- Android intent属性之component
- Android项目之HomeHealth基础学习3:Intent使用Component
- Intent中Component使用
- Intent使用Component
- Intent中Component使用
- Intent中Component使用
- Intent的属性-Component属性
- Intent属性component,action,category
- Intent的Component,Action和Category属性详解-android学习之旅(五十)
- Intent属性详解一 component属性
- Swing框架之Component
- Unity3d之组件Component
- Swing框架之Component
- Unity3d之组件Component
- Hibernate之component映射
- component之message
- binding之component
- 插入排序
- SSH网上商城环境搭建
- CentOS6.5 Gitolite构建Git镜像服务器
- 【机房合作】——备忘录模式
- Android SD卡简单的文件读写操作
- Intent之Component
- 算法训练 矩阵乘方
- 蓝桥杯:查找整数
- JavaScript概述
- 第一周------继续
- linux-matlab2015b安装步骤
- ViewController的生命周期
- csuoj-1716-Morse
- 选择排序