I am going one activity to another using an explicit Intent and I declare it in the manifest file.
<activity
android:name=".Activity2"
android:label="Activity 2">
<intent-filter
action android:name="com.tr.ACTIVITY2"
category android:name=”android.intent.category.DEFAULT">
</intent-filter>
</activity>
It works fine but one book uses intent-filter for this and I am confused about when we use intent filter.
When you use an explicit intent it’s like you tell Android “open Activity2”.
When you use an implicit intent you tell Android: “open an activity that can do these things“. these things is actually the filter that you write in the manifest for Activity2.
As an example, if you are in Activity1 and want to start Activity2:
You can have explicit:
Or implicit:
And in this case you should have in your manifest file something like: