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" />
相关推荐
Zender Han9 分钟前
Flutter Gradients 全面指南:原理、类型与实战使用
android·flutter·ios
2401_8345170716 分钟前
AD学习笔记-26 Active Routing
笔记·学习
火柴就是我19 分钟前
Flutter Path.computeMetrics() 的使用注意点
android·flutter
断剑zou天涯34 分钟前
【算法笔记】Manacher算法
java·笔记·算法
瑶光守护者1 小时前
【学习笔记】5G RedCap:智能回落5G NR驻留的接入策略
笔记·学习·5g
你想知道什么?1 小时前
Python基础篇(上) 学习笔记
笔记·python·学习
モンキー・D・小菜鸡儿2 小时前
Android 系统TTS(文字转语音)解析
android·tts
2501_915909062 小时前
iOS 反编译防护工具全景解析 从底层符号到资源层的多维安全体系
android·安全·ios·小程序·uni-app·iphone·webview
Swizard2 小时前
速度与激情:Android Python + CameraX 零拷贝实时推理指南
android·python·ai·移动开发
xian_wwq2 小时前
【学习笔记】可信数据空间的工程实现
笔记·学习