IntentFilter笔记

一、action

  1. <intent-filter>中可以有多个action,Intent只要匹配其中1个action即匹配成功
  2. <intent-filter>没有action,任何Intent无法与之匹配
  3. <intent-filter>中有action,Intent中没有action时可以与之匹配成功
  4. <intent-filter>中有action,Intent中也有action时,必须命中<intent-filter>中的一个action才能匹配成功

Intent中的action必须命中<intent-filter>中的一个action,才能匹配成功。Intent无action时匹配成功。

二、category

<intent-filter>中可以有多个category,Intent也可以有多个category

  1. 如果<intent-filter>不存在category,那么所有的intent都无法通过。
  2. 如果<intent-filter>存在category,如果Intent中不存在存在category,可以通过。
  3. 如果Intent中存在category,那么Intent中的所有category都包含在<intent-filter>中,才可以通过。

android.intent.category.DEFAULT:

Android把所有传给startActivity()的隐式意图当作他们包含至少一个类别:"android.intent.category.DEFAULT",因此,想要接收隐式意图的活动必须在它们的意图过滤器中包含"android.intent.category.DEFAULT"。

android.intent.category.BROWSABLE

三、data

首先<intent-filter>可以有多个data,Intent最多能有1个data。

<intent-filter>和Intent中的data必须完全匹配才能通过,也适用于通配符。

XML 复制代码
<data android:mimeType="text/plain"
   android:host="www.xxx.com"      
   android:path="/aa/bb"
   android:pathPattern="/b/*" 
   android:port="80"
   android:scheme="http" />
相关推荐
Wang's Blog3 分钟前
PostgreSQL笔记23:Checkpoint机制与脏页处理深度解析
笔记·postgresql
葡萄成熟时 !8 小时前
JAVA 常用API学习笔记
java·笔记·学习
DevOpenClub9 小时前
个人公开市场研究笔记功能需求文档
笔记
不会代码的小猴13 小时前
7. JSON
开发语言·c++·笔记·qt·算法·json
hunterandroid15 小时前
Android WebView JSBridge 治理实战:从线上白屏崩溃到协议化通信
android·前端
一个用户名i15 小时前
【Compose 系列】第 1 篇:认识 Compose,为什么要学它
android·android jetpack
GGMM78915 小时前
富士 EP‑3955D 变频器主板维修调试笔记
笔记·变频器·变频器维修
今儿敲了吗15 小时前
CN——网络层(上)
网络·笔记
PC2005-cloud15 小时前
Go学习笔记:基本概念与项目结构——GOPATH、Go Modules 与常用命令
笔记·学习·golang
极客猴子16 小时前
iPhone实时转写软件推荐:会议录音功能真实体验
android·人工智能·飞书