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" />
相关推荐
冬奇Lab9 小时前
Android触摸事件分发、手势识别与输入优化实战
android·源码阅读
城东米粉儿12 小时前
Android MediaPlayer 笔记
android
Jony_12 小时前
Android 启动优化方案
android
阿巴斯甜12 小时前
Android studio 报错:Cause: error=86, Bad CPU type in executable
android
张小潇12 小时前
AOSP15 Input专题InputReader源码分析
android
_小马快跑_16 小时前
Kotlin | 协程调度器选择:何时用CoroutineScope配置,何时用launch指定?
android
_小马快跑_16 小时前
Kotlin | 从SparseArray、ArrayMap的set操作符看类型检查的不同
android
_小马快跑_16 小时前
Android | 为什么有了ArrayMap还要再设计SparseArray?
android
_小马快跑_16 小时前
Android TextView图标对齐优化:使用LayerList精准控制drawable位置
android
_小马快跑_16 小时前
Kotlin协程并发控制:多线程环境下的顺序执行
android