Action test

An <intent-filter> element in the manifest file lists actions as <action> subelements. For example:

<action android:name="com.example.project.SHOW_CURRENT" /> <action android:name="com.example.project.SHOW_RECENT" /> <action android:name="com.example.project.SHOW PENDING" />

Filters and security

An intent filter cannot be relied on for security. While it opens a component to receiving only certain kinds of implicit intents, it does nothing to prevent explicit intents from targeting the component. Even though a filter restricts the intents a component will be asked to handle to certain actions and data sources, someone could always put together an explicit intent with a different action and data source, and name the component as the target.

</intent-filter>

As the example shows, while an Intent object names just a single action, a filter may list more than one. The list cannot be empty; a filter must contain at least one <action> element, or it will block all intents.

To pass this test, the action specified in the Intent object must match one of the actions listed in the filter. If the object or the filter does not specify an action, the results are as follows:

• If the filter fails to list any actions, there is nothing for an intent to match, so all intents fail the test. No intents can get through the filter.

• On the other hand, an Intent object that doesn't specify an action automatically passes the test — as long as the filter contains at least one action.

0 0

Post a comment