There are 2 types of intents that Android understands.
1. Explicit Intent
2. Implicit Intent


In an Explicit intent, you actually specify the activity that is required to respond to the intent. In other words, you explicitly designate the target component. This is typically used for application internal messages.


In an Implicit intent (the main power of the android design), you just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, you do not declare the target component and hence is typically used for activating components of other applications seamlessly.



Basically, an Intent object has the following information (among other things like Component name, extras and flags) which is of interest for implicit intents:
Action
Category
Data
So, the android platform compares these 3 (action, category and data) to something called "Intent Filters" that are declared by probable target components who are willing to accept Implicit Intent calls.
i.e. Intent Filters are the way of any component to advertise its own capabilities to the Android system. This is done declaratively in the AndroidManifest.xml file.

So here are some important points to remember:
Implicit Intents do not specify a target component
Components willing to receive implicit intents have to declare their ability to handle a specific intent by declaring intent filters
A component can declare any number of Intent Filters
There can be more than one component that declares the same Intent Filters and hence can respond to the same implicit intent. In that case the user is presented both the component options and he can choose which one he wants to continue with
You can set priorities for the intent filters to ensure the order of responses.
There are 3 tests conducted in order to match an intent with intent filters:
Action Test
Category Test
Data Test
For more details about them, you may visit the Android developer documentation here.

Comments

Popular Posts