Understanding Intent Categories

You can classify activities into categories so you can search for them based on a category name. For example, during startup Android looks for activities whose category (also known as a tag) is marked as CATEGORY_LAUNCHER. It then picks up these activity names and icons and places them on the home screen to launch.

Another example: Android looks for an activity tagged as CATEGORY_HOME to show the home screen during startup. Similarly, CATEGORY_GADGET marks an activity as suitable for embedding or reuse inside another activity.

The format of the string for a category like CATEGORY_LAUNCHER follows the category definition convention:

android.intent.category.LAUNCHER

You will need to know these text strings for category definitions because activities register their categories in the AndroidManifest.xml file as part of their activity-filter definitions. Here is an example:

<activity android:name=".HelloWorld"

android:label="@string/app_name"> <intent-filter>

<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

0 0

Post a comment