In this document

  1. Intent Objects
  2. Intent Resolution
  3. Common cases

Key classes

  1. Intent

The core components of an application — services — are activated through messages, called intents. Intent messaging is a facility for late run-time binding between components in the same or different applications. The intent itself, an Intent object, is a passive data structure holding an abstract description of an operation to be performed.

  • An Intent object is passed to Context.startService() to initiate a service or deliver new instructions to an ongoing service. Similarly, an intent can be passed to Context.bindService() to establish a connection between the calling component and a target service. It can optionally initiate the service if it's not already running.

The Mindroid system finds the appropriate service to respond to the intent, instantiating it if necessary.

This document begins with a description of Intent objects. It then describes the rules Mindroid uses to map intents to components — how it resolves which component should receive an intent message.

Intent Objects

An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as actions to be taken and the data to act on) plus information of interest to the Mindroid system. Principally, it can contain the following:

Component name
The name of the component that should handle the intent. This field is a ComponentName object — a combination of the fully qualified class name of the target component (for example "com.example.project.ExampleService") and the package name set in the manifest file of the application where the component resides (for example, "com.example.project").

The component name is mandatory. The Intent object is delivered to an instance of the designated class.

The component name is set by setComponent() or setClassName() and read by getComponent().

Key-value pairs for additional information that should be delivered to the component handling the intent.

The Intent object has a series of put...() methods for inserting various types of extra data and a similar set of get...() methods for reading the data. These methods parallel those for Bundle objects. In fact, the extras can be installed and read as a Bundle using the putExtras() and getExtras() methods.

Flags are currently not used.

Intent Resolution

  • Explicit intents designate the target component by its name (the component name field, mentioned earlier, has a value set).
  • Mindroid delivers an explicit intent to an instance of the designated target class. Nothing in the Intent object other than the component name matters for determining which component should get the intent.