Just An Application

December 5, 2010

The Android Intent Based APIs: Part One – Intents

Filed under: Android, Intents, Java, Mobile Java — Tags: , , , , — Simon Lewis @ 10:16 am

1. The Intent Model

  • An Intent is a message which can be sent between Android application components. The components can be in different Applications, or in the same one.

  • An Intent can function as either an operation, that is, it causes something to happen, or an event, that is, it indicates that something has happened.

  • An action is a unique identifier which can be used to specify either an operation to be performed by the recipient, or an event that has occurred, depending upon the context

  • A category is a unique identifier which is used by the system to specify a role within the Android Application/Component model that can be played by the recipient of an Intent.

  • A component can specify the Intents it wishes to receive using a filter.

  • A filter can specify the Intents to be received in terms of actions and/or categories.

  • When a category is specified by a component in a filter it specifies to the system the role or roles the component can play within the Application/Component model.

  • A component can specify that it should only receive Intents from components that are contained within applications that have been granted a specific permission.

  • An Intent can be sent to a single component, or to multiple components, depending upon the context in which it is used.

  • A component can specify the destination of an Intent explicitly using a component name.

  • An implicit Intent is an Intent which does does not contain the name of the component to which it should be sent

  • An explicit Intent is an Intent which contains the name of the component to which it should be sent

  • If the destination of an Intent is not explicitly specified, then the component or components to which it should be sent is/are determined dynamically using Intent resolution.

  • The system will, if necessary, automatically start an application containing a component which is the destination of an Intent.

  • A component can specify that an Intent only be sent to a component or components that has/have been granted a specific permission.

  • An Intent can contain

    • an action

    • data

    • the type of the data

    • a category or categories

    • the name of the component to which it should be sent

    • a collection of arbitrary data termed extras

    • a set of flags

  • Qualified names are used as unique identifiers.

  • A qualified name is akin to a Java package name or fully scoped class name, that is, it is a name of the form

    
        <qualified-name> := <prefix>  identifier
    
        <prefix>         := <qualified-name> '.' | <empty>
    	
    
  • Subject to the constraints imposed by the system on the ways in which Intents can be used, Applications are free to define the semantics of Intents in any way they choose.

2. Intent Constituents

2.1 Action

An Intent may contain an action. If present it is specified using a qualified name

The system pre-defines a number of actions but Applications can also define additional ones if they choose.

2.2 Data

An Intent may contain data. This is a somewhat misleading term since, if present, it is actually specified using a URI.

The URI can be used to identify what an operation should be performed upon, or what an event refers to.

2.3 Categories

An Intent may contain a set of categories. When specified by an Intent these are primarily used by the intent resolution process as part of the selection criteria.

A category is specified by a qualified name.

The system pre-defines a number of categories. Applications can define additional categories if they choose, but they cannot be made to affect the behaviour of the system in the same way as the built-in ones.

2.4 Component

An Intent may contain the name of the component to which it should be sent. If present this is specified as a package/class name pair.

2.5 Extras

An Intent may contain arbitrary data in the form of key/value pairs. Each key is specified as a qualified name. A value may be any of the primitive data types, a character sequence, a string, a parcelable object or a serializable object, or an array of any of these types, with the exception of serializable objects.

The system pre-defines a number of extras keys but Applications can also define additional ones if they choose.

2.6 Flags

An Intent can contain a set of flags. These are a form of meta-data and are not intended for use by the recipient(s) of the Intent. Instead they are used to affect aspects of the system’s behaviour with respect to the handling of the Intent and its recipient or recipients.

The set of flags that can be used is defined by the system. Applications cannot define their own flags.

3. Intent Resolution

The system determines the recipient or recipients(s) of an implicit Intent using the criteria specified by the currently defined set of component filters.

In addition to actions and categories a component’s filter may also specify as selection criteria

  • data types

  • data URI schemes

  • data URI authorities

  • data URI paths either as literals or patterns

For any given implicit Intent there is no guarantee that a matching component or components will be found.


Copyright (c) 2010 By Simon Lewis. All Rights Reserved.

Advertisements

1 Comment »

  1. […] Intent’s action is represented by a String which specifies a qualified […]

    Pingback by The Android Intent Based APIs: Part Two – The Intent class « Just An Application — December 12, 2010 @ 11:50 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.