AppWidgetManager.RequestPinAppWidget 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
請求將應用程式小工具釘選到目前啟動器上。
[Android.Runtime.Register("requestPinAppWidget", "(Landroid/content/ComponentName;Landroid/os/Bundle;Landroid/app/PendingIntent;)Z", "GetRequestPinAppWidget_Landroid_content_ComponentName_Landroid_os_Bundle_Landroid_app_PendingIntent_Handler", ApiSince=26)]
public virtual bool RequestPinAppWidget(Android.Content.ComponentName provider, Android.OS.Bundle? extras, Android.App.PendingIntent? successCallback);
[<Android.Runtime.Register("requestPinAppWidget", "(Landroid/content/ComponentName;Landroid/os/Bundle;Landroid/app/PendingIntent;)Z", "GetRequestPinAppWidget_Landroid_content_ComponentName_Landroid_os_Bundle_Landroid_app_PendingIntent_Handler", ApiSince=26)>]
abstract member RequestPinAppWidget : Android.Content.ComponentName * Android.OS.Bundle * Android.App.PendingIntent -> bool
override this.RequestPinAppWidget : Android.Content.ComponentName * Android.OS.Bundle * Android.App.PendingIntent -> bool
參數
- provider
- ComponentName
這是 ComponentName 針對 android.content.BroadcastReceiver BroadcastReceiver 你的 AppWidget 供應商。
- extras
- Bundle
如果不是 null,這個資料會傳給啟動器應用程式。 例如 #EXTRA_APPWIDGET_PREVIEW ,可用於自訂預覽。
- successCallback
- PendingIntent
若非 null,則在建立 widget 時會傳送此 intint。
傳回
true 如果啟動器支援這個功能, 請注意,API 會在不等待使用者回應的情況下回傳,因此從這個 API 取得true並不代表捷徑被釘選。
false 如果啟動器不支援此功能,或呼叫應用程式屬於使用者設定檔且首螢幕限制項目, 若呼叫應用程式啟用 App Lock,此方法將失敗並回傳 false。
- 屬性
備註
請求將應用程式小工具釘選到目前啟動器上。 是否接受這個請求由啟動器決定(可選擇顯示使用者確認)。 若請求被接受,來電者將獲得額外確認 #EXTRA_APPWIDGET_ID。
當用戶拒絕請求時,來電應用程式將無法獲得任何回應。
只有有前景活動或前景服務的應用程式才能呼叫它。 否則它會丟出 IllegalStateException。
當同一個套件連續多次呼叫這個 API 時,如何處理先前待處理的請求,就由啟動器決定。 例如,它可能會忽略之前的請求。
啟動器不會顯示與提供者相關的設定活動。 應用程式可以選擇顯示設定活動作為回調的回應,或在呼叫 API 前先顯示是否(可將各種設定封裝在 successCallback 中,以避免在 widgetID 已知前被持久化)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。