Android Guides | Samples

Android.App.IntentFilterAttribute Class

Generates the //intent-filter element within AndroidManifest.xml.

See Also: IntentFilterAttribute


[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
public sealed class IntentFilterAttribute : Attribute


The //intent-filter element is used to provide the types of intents that an activity, service, or broadcast receiver can respond to. The IntentFilterAttribute custom attribute is used by monodroid.exe when generating AndroidManifest.xml to to declaratively generate //intent-filter elements.

There are four sets of properties on IntentFilterAttribute:

  1. Properties which correspond to attributes on //intent-filter: IntentFilterAttribute.Icon, IntentFilterAttribute.Label, and IntentFilterAttribute.Priority.
  2. The IntentFilterAttribute.Actions property is used to generate //intent-filter/action elements.
  3. The IntentFilterAttribute.Categories property is used to generate //intent-filter/category elements.
  4. Properties which are used to generate a single //intent-filter/data element: IntentFilterAttribute.DataHost, IntentFilterAttribute.DataMimeType, IntentFilterAttribute.DataPath, IntentFilterAttribute.DataPathPattern, IntentFilterAttribute.DataPathPrefix, IntentFilterAttribute.DataPort, and IntentFilterAttribute.DataScheme.

The following type declaration:

C# Example

[IntentFilter (new[]{Intent.ActionMain},
    Categories=new[]{Intent.CategoryLauncher, Intent.CategorySampleCode}
public class MyActivity : Activity

will generate the following XML fragment within AndroidManifest.xml:

xml Example

<activity android:name="demo.MyActivity" android:label="MyActivity">
    <intent-filter android:icon="@drawable/myicon">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.SAMPLE_CODE" />
        <data android:scheme="something" android:host="" />

The IntentFilterAttribute custom attribute can be applied multiple times; each separate application will result in a separate //intent-filter element within AndroidManifest.xml.

The Intent type contains useful constants to use for action and category values.


Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:

The members of Android.App.IntentFilterAttribute are listed below.

See Also: Attribute

Public Constructors

Constructs and initializes a new IntentFilterAttribute instance with the specified actions.

Public Properties

ActionsString[]. The intent filter actions.
CategoriesString[]. The intent filter categories.
DataHostString. The host part of a URI authority.
DataMimeTypeString. A MIME media type, such as image/jpeg.
DataPathString. The path part of a URI.
DataPathPatternString. The path part of a URI.
DataPathPrefixString. The path part of a URI.
DataPortString. The port part of a URI.
DataSchemeString. The scheme part of a URI.
IconString. A reference to a drawable resource containing the image definition.
LabelString. A user-readable label for the parent component.
PriorityInt32. The intent filter's priority.