Android Guides | Samples

Android.App.IntentFilterAttribute Class

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

See Also: IntentFilterAttribute Members


[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: Inherited members from System.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.
Priorityint. The intent filter's priority.