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" />
相关推荐
ST.J4 小时前
webpack笔记
前端·笔记·webpack
姚瑞南5 小时前
【AI产品思路】AI 原型设计工具横评:产品经理视角下的 v0、Bolt 与 Lovable
人工智能·经验分享·笔记·aigc·产品经理
2501_915921435 小时前
iOS混淆工具实战 在线教育直播类 App 的课程与互动安全防护
android·安全·ios·小程序·uni-app·iphone·webview
Source.Liu5 小时前
【Python基础】 19 Rust 与 Python if 语句对比笔记
笔记·python·rust
程序员Xu6 小时前
【LeetCode热题100道笔记】二叉树的中序遍历
笔记·算法·leetcode
Source.Liu7 小时前
【Python基础】 18 Rust 与 Python print 函数完整对比笔记
笔记·python·rust
闻道且行之7 小时前
嵌入式|Linux中打开视频流的两种方式V4l2和opencv
linux·笔记·opencv·嵌入式
于顾而言7 小时前
【笔记】Software Engineering at Google
笔记·log4j·软件工程
前行的小黑炭7 小时前
Android Flow的其他使用:stateIn和冷流(普通Flow)
android·kotlin
tran_sient8 小时前
【Android】制造一个ANR并进行简单分析
android·anr