Jon Rumsey

An online markdown blog and knowledge repository.


Project maintained by nojronatron Hosted on GitHub Pages — Theme by mattgraham

Read Class 38

Intent Filters, and Implicit and Explicit Intents

Resources

Intent Filters

Implicit vs Explicit Intents

Intent Filters

Action requests can be set up so that your App appears as a handler for an Action.

E.g.: When tapping 'share' a list of apps appears to select from (Facebook, Twitter, Messenger, etc) - your App can be on that list by supporting ACTION_SEND.

Allowing other Apps to do this requires adding <intent-filter> to the <activity> element in the manifest file.

Ensure your implemented Intent Filters are specific.

Intent Filter Criteria are:

See the code in this doc for simple examples of the above implementations.

Incoming Intents specify:

Multiple instances of action, category, and data elements can be declared within each intent-filter.

Separate mutually exclusive action:data pairs with separate intent filters.

Read-in the properties of the incoming Intent to determine an action to take:

Call getIntent() within onCreate() or onStart() lifecycle methods.

Use 'setResult()' to return a result to the activity that invoked this Activity.

Implicit vs Explicit Intents

Explicit: Specify which App will satisfy an Intent.

Implicit: No specific component is named.

The System is responsible for managing Implicit and Explicit Intent operations.

Compares Intent content to Intent Filters in the Manifest File of the 'other App' on the device.

When using a Service: Always use an explicit Intent, for security reasons.

Return to Root README