Android Intent

Intent is the negotiator between two activities or between two applications. It gives the ability to pass messages and data between the two entities.

When writing applications for mobile, Intent is very handy, since it gives access to a lot of the OS services like opening the camera, a browser, displaying notifications and so on.

Intent Resolution

Intents can be divided into two groups:
Explicit intents designate the target component by its name.
Implicit intents do not name a target. Implicit intents are often used to activate components in other applications.
To resolve an Explicit Intent Android uses only the name of the Component.
Android resolves Implicit Intent by comparing the contents of the Intent object to intent filters, structures associated with components that can potentially receive intents.
Filters advertise the capabilities of a component and delimit the intents it can handle. A component with filters can receive both explicit and implicit intents.
Only three aspects of an Intent object are consulted when the object is tested against an intent filter:
. action
. data (both URI and data type)
. category
The extras and flags play no part in resolving which component receives an intent.

Intent filters

To inform the system which implicit intents they can handle, activities, services, and broadcast receivers can have one or more intent filters.
An explicit intent is always delivered to its target, no matter what it contains; the filter is not consulted.
But an implicit intent is delivered to a component only if it can pass through one of the component’s filters.
An intent filter is an instance of the IntentFilter class.
A filter has fields that parallel the action, data, and category fields of an Intent object.
An implicit intent is tested against the filter in all three areas.

<intent-filter>
      <action android:name="com.example.project.SHOW_CURRENT">
      <action android:name="com.example.project.SHOW_RECENT">
      <action android:name="com.example.project.SHOW_PENDING">
      </action></action></action></intent-filter>

Category test

<intent-filter>
      <category android:name="android.intent.category.DEFAULT">
      <category android:name="android.intent.category.BROWSABLE">
      </category></category></intent-filter>