Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<activity> without <intent-filter> in AndroidManifest.xml

I know I need to use to enable an activity to receive an Intent like this (not main activity).

<activity android:name=".MyApp_2ndActivity">
    <intent-filter>
         <action android:name="android.intent.action.VIEW" />
         <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

However, I found it can be triggered too if "intent-filter" is removed, like this.

<activity android:name=".MyApp_2ndActivity">
</activity>

I am wondering what difference is in these 2 formats?

like image 314
user1443721 Avatar asked Feb 06 '26 14:02

user1443721


1 Answers

See here: http://developer.android.com/guide/components/intents-filters.html

The difference is the second one can only be started using an explicit Intent -- one which names the component it wants to start. The first one can be started by an implicit Intent -- one which does not specify the exact component but contains information for the system to find an appropriate match for. The intent filters are used by the system for resolving such intents.

like image 116
Karakuri Avatar answered Feb 09 '26 07:02

Karakuri