語言

Notification.WearableExtender.SetDisplayIntent(PendingIntent) 方法

定義

此方法在 API 等級 29 被棄用。

[Android.Runtime.Register("setDisplayIntent", "(Landroid/app/PendingIntent;)Landroid/app/Notification$WearableExtender;", "")]
public Android.App.Notification.WearableExtender? SetDisplayIntent(Android.App.PendingIntent? intent);
[<Android.Runtime.Register("setDisplayIntent", "(Landroid/app/PendingIntent;)Landroid/app/Notification$WearableExtender;", "")>]
member this.SetDisplayIntent : Android.App.PendingIntent -> Android.App.Notification.WearableExtender

參數

intent
PendingIntent

PendingIntent:活動的PendingIntent

傳回

此物件用於方法鏈結

屬性

備註

此方法在 API 等級 29 被棄用。 顯示意圖不再支援。

在顯示此通知時,請在活動檢視中設定啟動意圖。 所提供的待定意圖應該是針對某項活動。

Intent displayIntent = new Intent(context, MyDisplayActivity.class);
PendingIntent displayPendingIntent = PendingIntent.getActivity(context,
        0, displayIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
Notification notif = new Notification.Builder(context, CHANNEL_ID)
        .extend(new Notification.WearableExtender()
                .setDisplayIntent(displayPendingIntent)
                .setCustomSizePreset(Notification.WearableExtender.SIZE_MEDIUM))
        .build();

啟動的活動必須允許嵌入,必須匯出,且任務關聯性應為空。 也建議使用裝置預設的燈光主題。

條目 AndroidManifest.xml 範例:

<activity android:name="com.example.MyDisplayActivity"
    android:exported="true"
    android:allowEmbedded="true"
    android:taskAffinity=""
    android:theme="@android:style/Theme.DeviceDefault.Light" />

Android 參考資料。android.app.Notification.WearableExtender.setDisplayIntent

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

適用於