在Android的隐式调用中,如果没有设置action只设置了Category就报ActivityNotFoundException;DEVGuide不是说如果Action,Category,Data通过测试就可以了吗,而且Intent的action也可以为空On the other hand, an Intent object that doesn't specify an action automatically passes the test — as long as the filter contains at least one action.
出错代码如下:(ActivityNotFoundException)
Test.java
Intent intent = new Intent();
//intent.setAction("testAction");//该行如果放开注释就正确
intent.addCategory("testCategory");//如果只设置action不添加category也正确
startActivity(intent);
AndroidManifest.xml
<activity android:name=".Test2">
<intent-filter>
<action android:name="testAction"></action>
<category android:name="testCategory"></category>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>