描述一下 Intent 和 IntentFilter?
Android 中通过 Intent 对象来表示一条消息,一个 Intent 对象不仅包含有这个消息的目的地,还可以包含消
息的内容,这好比一封 Email,其中不仅应该包含收件地址,还可以包含具体的内容。对于一个 Intent 对象,消息
“目的地”是必须的,而内容则是可选项。
通过 Intent 可以实现各种系统组件的调用与激活.
IntentFilter: 可以理解为邮局或者是一个信笺的分拣系统…
这个分拣系统通过 3 个参数来识别
Action: 动作 view
Data: 数据 uri uri
Category : 而外的附加信息
Action 匹配
Action 是一个用户定义的字符串,用于描述一个 Android 应用程序组件,一个 IntentFilter 可以包含多个
Action。在 AndroidManifest.xml 的 Activity 定义时可以在其 <intent-filter >节点指定一个 Action 列表用于标
示 Activity 所能接受的“动作”,例如:
intent-filter >
<action android:name="android.intent.action.MAIN" />
<action android:name="cn.loaderman.action" />
……
</intent-filter>
如果我们在启动一个 Activity 时使用这样的 Intent 对象:
Intent intent =new Intent();
intent.setAction("com.loaderman.action")
那么所有的 Action 列表中包含了“cn.itheima”的 Activity 都将会匹配成功。
Android 预定义了一系列的 Action 分别表示特定的系统动作。这些 Action 通过常量的方式定义在
android.content. Intent 中,以“ACTION_”开头。我们可以在 Android 提供的文档中找到它们的详细说明。
URI 数据匹配
一个 Intent 可以通过 URI 携带外部数据给目标组件。在 <intent-filter >节点中,通过 <data/>节点匹配外部
数据。
mimeType 属性指定携带外部数据的数据类型,scheme 指定协议,host、port、path 指定数据的位置、端口、
和路径。如下:
<data android:mimeType="mimeType" android:scheme="scheme"
android:host="host" android:port="port" android:path="path"/>
电话的 uri tel: 12345
http://www.baidu.com
自己定义的 uri loaderman://cn.loaderman/person/10
如果在 Intent Filter 中指定了这些属性,那么只有所有的属性都匹配成功时 URI 数据匹配才会成功。
Category 类别匹配
<intent-filter >节点中可以为组件定义一个 Category 类别列表,当 Intent 中包含这个列表的所有项目时
Category 类别匹配才会成功。
描述一下 Intent 和 IntentFilter?的更多相关文章
- android学习日记20--连接组件之Intent和IntentFilter
上次刚了解完Android的四大组件,现在学习组件间通信的Intent和IntentFilter 一.Intent 1.简述 Intent(意图)在应用程序运行时连接两个不同组件,是一种运行时的绑定机 ...
- Android应用程序组件之间的通信Intent和IntentFilter
Android应用程序的基本组件,这些基本组建除了Content Provider之外,几乎全部都是依靠Intent对象来激活和通信的. 下面介绍Intent类,并通过例子来说明Intent一般用法 ...
- Android的Intent和IntentFilter应用说明一例
很多人对文档中的Intent和IntentFilter不理解是什么意思,我这里举例解释下. Intent字面意思就是目标,目的.通俗一点,需要达成某些目标,则需要提供一些动作,这些目标的分类,以及达成 ...
- Intent和IntentFilter简介
Intent和IntentFilter简介 Intent和IntentFilter简介 意图Intent分类: 显式意图:利用class找到对方,在同一个应用程序类可以方便使用,但是在不同的应用程序无 ...
- Intent和IntentFilter详解
Intent用于启动Activity,Service, 以及BroadcastReceiver三种组件, 同时还是组件之间通信的重要媒介. 使用Intent启动组件的优势1, Intent为组件的启动 ...
- [转]android笔记--Intent和IntentFilter详解
Intent用于启动Activity, Service, 以及BroadcastReceiver三种组件, 同时还是组件之间通信的重要媒介. 使用Intent启动组件的优势1, Intent为组件的启 ...
- Intent及IntentFilter具体解释
Intent用于启动Activity, Service, 以及BroadcastReceiver三种组件, 同一时候还是组件之间通信的重要媒介. 使用Intent启动组件的优势 1, Intent为组 ...
- android笔记--Intent和IntentFilter详解
本文转载自:https://www.cnblogs.com/liushengjie/archive/2012/08/30/2663066.html 本文转载自:https://www.cnblogs. ...
- Intent过滤,intent-filter
Intent过滤 编写:kesenhoo - 原文:http://developer.android.com/training/basics/intents/filters.html 前两节课主要讲了 ...
随机推荐
- MyCat配置简述以及mycat全局ID
Mycat可以直接下载解压,简单配置后可以使用,主要配置项如下: 1. log4j2.xml:配置MyCat日志,包括位置,格式,单个文件大小 2. rule.xml: 配置分片规则 3. schem ...
- ThinkPHP依赖注入
D:\wamp64\www\thinkphp5.1\tp5.1\application\index\controller\Demo1.php文件 <?php namespace app\inde ...
- 常用sql:按照表中的某一列对数据进行分组,统计数据条数
select FROM_UNIXTIME(start_time,'%Y-%m-%d')as date,COUNT(*) FROM random_num GROUP BY FROM_UNIXTIME(s ...
- 构建一个highcharts
示例:http://www.helloweba.com/demo/highcharts/line.html <!doctype html> <html lang="en&q ...
- idea:spring initializr无web勾选,maven方式搭建springboot项目。jdk7创建springboot项目的版本不兼容问题。
一.idea 使用spring initializr不选择web搭建springboot项目 1.file => new => project 2.直接next到finish结束. 3.完 ...
- Linux双网口配置时重复配置DEFROUTE和GATEWAY
配置一台机器时,沿袭了原有网口配置,修改网口名,把em1全部修改改为eth0 mv ifcfg-em1 ifcfg-eth0 mv ifcfg-em2 ifcfg-eth1 改完以后,机器变得不稳定, ...
- 红帽Linux故障定位技术详解与实例(1)
红帽Linux故障定位技术详解与实例(1) 2011-09-28 14:26 圈儿 BEAREYES.COM 我要评论(0) 字号:T | T 在线故障定位就是在故障发生时, 故障所处的操作系统环境仍 ...
- 如何理解react中的super() super(props)
class WebSite extends React.Component { constructor() { super(); this.state = { name: "菜鸟教程&quo ...
- buuctf@ciscn_2019_c_1
from pwn import * context.log_level='debug' #io=remote('node3.buuoj.cn',29121) io=process('./ciscn_2 ...
- 微信小游戏egret开发包括p2引擎小结
用egret + p2 做一个类似投球的小游戏,坑大致如下: 1.p2引擎与egret坐标不同注意转换,横坐标没什么,纵坐标egret.y = stageHeight - body.position[ ...