Android Guides | Samples

Android.Content.IntentFilter Class

Structured description of Intent values to be matched.

See Also: IntentFilter

Syntax

[Android.Runtime.Register("android/content/IntentFilter", DoNotGenerateAcw=true)]
public class IntentFilter : Object, IParcelable, IDisposable

Remarks

Structured description of Intent values to be matched. An IntentFilter can match against actions, categories, and data (either via its type, scheme, and/or path) in an Intent. It also includes a "priority" value which is used to order multiple matching filters.

IntentFilter objects are often created in XML as part of a package's NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifest file, using NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#AndroidManifestIntentFilter tags.

There are three Intent characteristics you can filter on: the action, data, and categories. For each of these characteristics you can provide multiple possible matching values (via IntentFilter.AddAction(String), IntentFilter.AddDataType(String), IntentFilter.AddDataScheme(String), IntentFilter.AddDataSchemeSpecificPart(String,Pattern), IntentFilter.AddDataAuthority(String,String), IntentFilter.AddDataPath(String,Pattern), and IntentFilter.AddCategory(String), respectively). For actions, the field will not be tested if no values have been given (treating it as a wildcard); if no data characteristics are specified, however, then the filter will only match intents that contain no data.

The data characteristic is itself divided into three attributes: type, scheme, authority, and path. Any that are specified must match the contents of the Intent. If you specify a scheme but no type, only Intent that does not have a type (such as mailto:) will match; a content: URI will never match because they always have a MIME type that is supplied by their content provider. Specifying a type with no scheme has somewhat special meaning: it will match either an Intent with no URI field, or an Intent with a content: or file: URI. If you specify neither, then only an Intent with no data or type will match. To specify an authority, you must also specify one or more schemes that it is associated with. To specify a path, you also must specify both one or more authorities and one or more schemes it is associated with.

Developer Guides

For information about how to create and resolve intents, read the Intents and Intent Filters developer guide.

Filter Rules

A match is based on the following rules. Note that for an IntentFilter to match an Intent, three conditions must hold: the action and category must match, and the data (both the data type and data scheme+authority+path if specified) must match (see IntentFilter.Match(ContentResolver,Intent,Intent,Intent) for more details on how the data fields match).

Action matches if any of the given values match the Intent action; if the filter specifies no actions, then it will only match Intents that do not contain an action.

Data Type matches if any of the given values match the Intent type. The Intent type is determined by calling Intent.ResolveType(ContentResolver). A wildcard can be used for the MIME sub-type, in both the Intent and IntentFilter, so that the type "audio/*" will match "audio/mpeg", "audio/aiff", "audio/*", etc. Note that MIME type matching here is case sensitive, unlike formal RFC MIME types! You should thus always use lower case letters for your MIME types.

Data Scheme matches if any of the given values match the Intent data's scheme. The Intent scheme is determined by calling Intent.Data and Uri.Scheme on that URI. Note that scheme matching here is case sensitive, unlike formal RFC schemes! You should thus always use lower case letters for your schemes.

Data Scheme Specific Part matches if any of the given values match the Intent's data scheme specific part and one of the data schemes in the filter has matched the Intent, or no scheme specific parts were supplied in the filter. The Intent scheme specific part is determined by calling Intent.Data and Uri.SchemeSpecificPart on that URI. Note that scheme specific part matching is case sensitive.

Data Authority matches if any of the given values match the Intent's data authority and one of the data schemes in the filter has matched the Intent, or no authories were supplied in the filter. The Intent authority is determined by calling Intent.Data and Uri.Authority on that URI. Note that authority matching here is case sensitive, unlike formal RFC host names! You should thus always use lower case letters for your authority.

Data Path matches if any of the given values match the Intent's data path and both a scheme and authority in the filter has matched against the Intent, or no paths were supplied in the filter. The Intent authority is determined by calling Intent.Data and Uri.Path on that URI.

Categories match if all of the categories in the Intent match categories given in the filter. Extra categories in the filter that are not in the Intent will not cause the match to fail. Note that unlike the action, an IntentFilter with no categories will only match an Intent that does not have any categories.

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Content.IntentFilter are listed below.

See Also: Object

Public Constructors

New empty IntentFilter.
New IntentFilter containing a copy of an existing filter.
New IntentFilter that matches a single action with no data.
New IntentFilter that matches a single action and data type.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
SystemHighPriorityIntentFilterPriority (1000). The filter IntentFilter.Priority value at which system high-priority receivers are placed; that is, receivers that should execute before application code.
const
SystemLowPriorityIntentFilterPriority (-1000). The filter IntentFilter.Priority value at which system low-priority receivers are placed; that is, receivers that should execute after application code.

Public Properties

[read-only]
static
CreatorIParcelableCreator.
PriorityInt32. Return the priority of this filter.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

ActionsIterator() : IIterator
Return an iterator over the filter's actions.
AddAction(String)
Add a new Intent action to match against.
AddCategory(String)
Add a new Intent category to match against.
AddDataAuthority(String, String)
Add a new Intent data authority to match against.
AddDataPath(String, Pattern)
Add a new Intent data path to match against.
AddDataScheme(String)
Add a new Intent data scheme to match against.
AddDataSchemeSpecificPart(String, Pattern)
Add a new Intent data "scheme specific part" to match against.
AddDataType(String)
Add a new Intent data type to match against.
AuthoritiesIterator() : IIterator
Return an iterator over the filter's data authorities.
CategoriesIterator() : IIterator
Return an iterator over the filter's categories.
CountActions() : Int32
Return the number of actions in the filter.
CountCategories() : Int32
Return the number of categories in the filter.
CountDataAuthorities() : Int32
Return the number of data authorities in the filter.
CountDataPaths() : Int32
Return the number of data paths in the filter.
CountDataSchemes() : Int32
Return the number of data schemes in the filter.
CountDataSchemeSpecificParts() : Int32
Return the number of data scheme specific parts in the filter.
CountDataTypes() : Int32
Return the number of data types in the filter.
static
Create(String, String) : IntentFilter
Create a new IntentFilter instance with a specified action and MIME type, where you know the MIME type is correctly formatted.
DescribeContents() : Int32
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
Dump(IPrinter, String)
GetAction(Int32) : String
Return an action in the filter.
GetCategory(Int32) : String
Return a category in the filter.
GetDataAuthority(Int32) : IntentFilter+AuthorityEntry
Return a data authority in the filter.
GetDataPath(Int32) : PatternMatcher
Return a data path in the filter.
GetDataScheme(Int32) : String
Return a data scheme in the filter.
GetDataSchemeSpecificPart(Int32) : PatternMatcher
Return a data scheme specific part in the filter.
GetDataType(Int32) : String
Return a data type in the filter.
HasAction(String) : Boolean
Is the given action included in the filter? Note that if the filter does not include any actions, false will always be returned.
HasCategory(String) : Boolean
Is the given category included in the filter?
HasDataAuthority(Uri) : Boolean
Is the given data authority included in the filter? Note that if the filter does not include any authorities, false will always be returned.
HasDataPath(String) : Boolean
Is the given data path included in the filter? Note that if the filter does not include any paths, false will always be returned.
HasDataScheme(String) : Boolean
Is the given data scheme included in the filter? Note that if the filter does not include any scheme, false will always be returned.
HasDataSchemeSpecificPart(String) : Boolean
Is the given data scheme specific part included in the filter? Note that if the filter does not include any scheme specific parts, false will always be returned.
HasDataType(String) : Boolean
Is the given data type included in the filter? Note that if the filter does not include any type, false will always be returned.
Match(ContentResolver, Intent, Boolean, String) : MatchResults
Test whether this filter matches the given intent.
Match(String, String, String, Uri, ICollection<string>, String) : MatchResults
MatchAction(String) : Boolean
Match this filter against an Intent's action.
MatchCategories(ICollection<string>) : String
MatchData(String, String, Uri) : MatchResults
Match this filter against an Intent's data (type, scheme and path).
MatchDataAuthority(Uri) : MatchResults
Match this intent filter against the given Intent data.
PathsIterator() : IIterator
Return an iterator over the filter's data paths.
ReadFromXml(XmlReader)
SchemesIterator() : IIterator
Return an iterator over the filter's data schemes.
SchemeSpecificPartsIterator() : IIterator
Return an iterator over the filter's data scheme specific parts.
TypesIterator() : IIterator
Return an iterator over the filter's data types.
WriteToParcel(Parcel, ParcelableWriteFlags)
Flatten this object in to a Parcel.
WriteToXml(IXmlSerializer)
Write the contents of the IntentFilter as an XML stream.