語言

Intent.Selector 屬性

定義

回傳與此意圖相關的特定選擇器。 -或者- 為這個意圖設定一個選擇器。

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

屬性值

回傳與此意圖相關的特定選擇器。 若無,則回傳 null。 更多資訊請參見 setSelector(Intent)。

屬性

備註

財產取得者文件:

回傳與此意圖相關的特定選擇器。 若無,則回傳 null。 如需相關資訊,請參閱 #setSelector 。

Java 文件 android.content.Intent.getSelector()。

屬性設定文件:

為此意圖設定選擇器。 這是對意圖所匹配事物類型的調整。 如果選擇器已設定,則在尋找能處理意圖的實體時會使用它,而非意圖的主要內容。 這讓你能建立包含通用協議的意圖,同時更針對它進行目標。

例如,這類情況 #CATEGORY_APP_BROWSER可能被用在 。 這個類別允許你建立一個意圖來啟動瀏覽器應用程式。 然而,應用程式的正確入口點是#ACTION_MAIN#CATEGORY_LAUNCHER#setComponent(ComponentName)用來指定要啟動的應用程式。 如果你用不同的方式啟動瀏覽器,使用者之前或之後用正常方式啟動瀏覽器,可能會發生不想要的行為,因為兩者不符。 相反地,你可以用 MAIN 動作建立一個 Intent(但尚未指定 ComponentName),並設定一個選擇器,#ACTION_MAIN#CATEGORY_APP_BROWSER讓它專門指向瀏覽器的活動。

設定選擇器不會影響 和 #filterEquals(Intent)的#filterHashCode()行為。 這是選擇者期望的行為之一——它不影響意圖的基本意義,只是決定誰能處理時會與意圖匹配哪些內容。

你不能同時用選擇器和 #setPackage(String) 同一個基礎意圖。

Java 文件 android.content.Intent.setSelector(android.content.Intent)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

另請參閱