Intent.Selector Property

Definition

Return the specific selector associated with this Intent. -or- Set a selector for this Intent.

public virtual Android.Content.Intent? Selector { [Android.Runtime.Register("getSelector", "()Landroid/content/Intent;", "GetGetSelectorHandler")] get; [Android.Runtime.Register("setSelector", "(Landroid/content/Intent;)V", "GetSetSelector_Landroid_content_Intent_Handler")] set; }
[<get: Android.Runtime.Register("getSelector", "()Landroid/content/Intent;", "GetGetSelectorHandler")>]
[<set: Android.Runtime.Register("setSelector", "(Landroid/content/Intent;)V", "GetSetSelector_Landroid_content_Intent_Handler")>]
member this.Selector : Android.Content.Intent with get, set

Property Value

Attributes

Remarks

Property getter documentation:

Return the specific selector associated with this Intent. If there is none, returns null. See #setSelector for more information.

Java documentation for android.content.Intent.getSelector().

Property setter documentation:

Set a selector for this Intent. This is a modification to the kinds of things the Intent will match. If the selector is set, it will be used when trying to find entities that can handle the Intent, instead of the main contents of the Intent. This allows you build an Intent containing a generic protocol while targeting it more specifically.

An example of where this may be used is with things like #CATEGORY_APP_BROWSER. This category allows you to build an Intent that will launch the Browser application. However, the correct main entry point of an application is actually #ACTION_MAIN#CATEGORY_LAUNCHER with #setComponent(ComponentName) used to specify the actual Activity to launch. If you launch the browser with something different, undesired behavior may happen if the user has previously or later launches it the normal way, since they do not match. Instead, you can build an Intent with the MAIN action (but no ComponentName yet specified) and set a selector with #ACTION_MAIN and #CATEGORY_APP_BROWSER to point it specifically to the browser activity.

Setting a selector does not impact the behavior of #filterEquals(Intent) and #filterHashCode(). This is part of the desired behavior of a selector -- it does not impact the base meaning of the Intent, just what kinds of things will be matched against it when determining who can handle it.

You can not use both a selector and #setPackage(String) on the same base Intent.

Java documentation for android.content.Intent.setSelector(android.content.Intent).

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.

Applies to

See also