自定义的IntentFileter 无法找到activity

<intent-filter >
<action android:name="com.leo.enjoytime.VIEW"/>
</intent-filter>

自定义的IntentFileter出现异常  No Activity found to handle Intent { com.leo.View (has extras) }

结果查资料发现自定义的action同时需要定义category

比如:

<intent-filter >
<action android:name="com.leo.enjoytime.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

每一个通过startActivity()方法发出的隐式Intent都至少有一个category,就是 "android.intent.category.DEFAULT",

所以只要是想接收一个隐式Intent的Activity都应该包括"android.intent.category.DEFAULT" category,不然将导致 Intent 匹配失败。

原文地址:https://www.cnblogs.com/krislight1105/p/5270148.html