Supplying Anonymous Actions to Applications

To use this mechanism to make your Activity's actions available anonymously for existing applications, publish them using intent-filter tags within their manifest nodes.

The Intent Filter describes the action it performs and the data upon which it can be performed. The latter will be used during the Intent resolution process to determine when this action should be available. The category tag must be either ALTERNATIVE or SELECTED_ALTERNATIVE or both. The text used for the Menu Items is specified by the android:label attribute.

Listing 5-10 shows an example of an Intent Filter used to advertise an Activity's ability to nuke moon-bases from orbit.

Cant Act Plcke-r Teit

LISTING 5-10: Advertising-supported Activity actions Available for downloadon <activity android:name=".NostromoController"> Wrox.com <intent-filter android:label="Nuke From Orbit">

<action android:name="com.pad.nostromo.NUKE_FROM_ORBIT" /> <data android:mimeType="vnd.moonbase.cursor.item/*"/> <category android:name="android.intent.category.ALTERNATIVE" /> <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> </intent-filter> </activity>

The Content Provider and other code needed for this example to run aren't provided; in the following sections you'll see how to write the code that adds this action dynamically to another Activity's Menu.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment