android - About the XML|intent-filter -


@override public void onclick(view v) {    intent intent = new intent("com.example.ui05.action_start");                 intent.addcategory("com.example.ui05.my_category");    startactivity(intent); } 

the relevant manifest is:

   <activity android:name=".secondactivity" >         <intent-filter>             <action android:name="com.example.ui05.action_start" />             <category android:name="android.intent.category.default" />              <category android:name="android.intent.category.category" />         </intent-filter>       </activity>        @override    public void onclick(view v) {       intent intent = new intent("com.example.ui05.action_start");                               startactivity(intent);    } 

the relevent manifest is:

   <activity android:name=".secondactivity" >         <intent-filter>             <action android:name="com.example.ui05.action_start" />             <category android:name="android.intent.category.default" />          </intent-filter>       </activity>   

why first situation give exception :

android.content.activitynotfoundexception: no activity found handle     intent { act=com.example.ui05.action_start cat=[com.example.ui05.my_category] } 

the second situation ok.

your intent filter doesn't include category category you're specifying in intent. change intent filter category specifying android.intent.category.category com.example.ui05.my_category , should work.


Comments