IntentFilter Class

Definition

Structured description of Intent values to be matched.

[Android.Runtime.Register("android/content/IntentFilter", DoNotGenerateAcw=true)]
public class IntentFilter : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/content/IntentFilter", DoNotGenerateAcw=true)>]
type IntentFilter = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
IntentFilter
Attributes
Implements

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 android.R.styleable#AndroidManifest AndroidManifest.xml file, using android.R.styleable#AndroidManifestIntentFilter intent-filter tags.

There are three Intent characteristics you can filter on: the <em>action</em>, <em>data</em>, and <em>categories</em>. For each of these characteristics you can provide multiple possible matching values (via #addAction, #addDataType, #addDataScheme, #addDataSchemeSpecificPart, #addDataAuthority, #addDataPath, and #addCategory, respectively). For actions, if no data characteristics are specified, 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.

<div class="special reference"> <h3>Developer Guides</h3>

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

</div>

<h3>Filter Rules</h3>

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

<strong>Action</strong> 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.

<strong>Data Type</strong> matches if any of the given values match the Intent type. The Intent type is determined by calling Intent#resolveType. 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. <em>Note that MIME type matching here is <b>case sensitive</b>, unlike formal RFC MIME types!</em> You should thus always use lower case letters for your MIME types.

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

<strong>Data Scheme Specific Part</strong> matches if any of the given values match the Intent's data scheme specific part <em>and</em> one of the data schemes in the filter has matched the Intent, <em>or</em> no scheme specific parts were supplied in the filter. The Intent scheme specific part is determined by calling Intent#getData and android.net.Uri#getSchemeSpecificPart on that URI. <em>Note that scheme specific part matching is <b>case sensitive</b>.</em>

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

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

<strong>Categories</strong> match if <em>all</em> 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.

Java documentation for android.content.IntentFilter.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

IntentFilter()

New empty IntentFilter.

IntentFilter(IntentFilter)

New IntentFilter containing a copy of an existing filter.

IntentFilter(IntPtr, JniHandleOwnership)

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

IntentFilter(String)

New IntentFilter that matches a single action with no data.

IntentFilter(String, String)

New IntentFilter that matches a single action and data type.

Fields

SystemHighPriority
Obsolete.

The filter #setPriority value at which system high-priority receivers are placed; that is, receivers that should execute before application code.

SystemLowPriority
Obsolete.

The filter #setPriority value at which system low-priority receivers are placed; that is, receivers that should execute after application code.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
Priority

Return the priority of this filter. -or- Modify priority of this filter.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

ActionsIterator()

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.

AsPredicate()

Return a Predicate which tests whether this filter matches the given <var>intent</var>.

AsPredicateWithTypeResolution(ContentResolver)

Return a Predicate which tests whether this filter matches the given <var>intent</var>.

AuthoritiesIterator()

Return an iterator over the filter's data authorities.

CategoriesIterator()

Return an iterator over the filter's categories.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CountActions()

Return the number of actions in the filter.

CountCategories()

Return the number of categories in the filter.

CountDataAuthorities()

Return the number of data authorities in the filter.

CountDataPaths()

Return the number of data paths in the filter.

CountDataSchemes()

Return the number of data schemes in the filter.

CountDataSchemeSpecificParts()

Return the number of data scheme specific parts in the filter.

CountDataTypes()

Return the number of data types in the filter.

Create(String, String)

Create a new IntentFilter instance with a specified action and MIME type, where you know the MIME type is correctly formatted.

DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Dump(IPrinter, String)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetAction(Int32)

Return an action in the filter.

GetCategory(Int32)

Return a category in the filter.

GetDataAuthority(Int32)

Return a data authority in the filter.

GetDataPath(Int32)

Return a data path in the filter.

GetDataScheme(Int32)

Return a data scheme in the filter.

GetDataSchemeSpecificPart(Int32)

Return a data scheme specific part in the filter.

GetDataType(Int32)

Return a data type in the filter.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
HasAction(String)

Is the given action included in the filter? Note that if the filter does not include any actions, false will <em>always</em> be returned.

HasCategory(String)

Is the given category included in the filter?

HasDataAuthority(Uri)

Is the given data authority included in the filter? Note that if the filter does not include any authorities, false will <em>always</em> be returned.

HasDataPath(String)

Is the given data path included in the filter? Note that if the filter does not include any paths, false will <em>always</em> be returned.

HasDataScheme(String)

Is the given data scheme included in the filter? Note that if the filter does not include any scheme, false will <em>always</em> be returned.

HasDataSchemeSpecificPart(String)

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 <em>always</em> be returned.

HasDataType(String)

Is the given data type included in the filter? Note that if the filter does not include any type, false will <em>always</em> be returned.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Match(ContentResolver, Intent, Boolean, String)

Test whether this filter matches the given <var>intent</var>.

Match(String, String, String, Uri, ICollection<String>, String)

Test whether this filter matches the given intent data.

MatchAction(String)

Match this filter against an Intent's action.

MatchCategories(ICollection<String>)

Match this filter against an Intent's categories.

MatchData(String, String, Uri)

Match this filter against an Intent's data (type, scheme and path).

MatchDataAuthority(Uri)

Match this intent filter against the given Intent data.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
PathsIterator()

Return an iterator over the filter's data paths.

ReadFromXml(XmlReader)
SchemesIterator()

Return an iterator over the filter's data schemes.

SchemeSpecificPartsIterator()

Return an iterator over the filter's data scheme specific parts.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
TypesIterator()

Return an iterator over the filter's data types.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

WriteToXml(IXmlSerializer)

Write the contents of the IntentFilter as an XML stream.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to