共用方式為


NotificationListenerService.CancelNotification 方法

定義

多載

CancelNotification(String)

通知管理員關閉單一通知。

CancelNotification(String, String, Int32)
已淘汰.

通知管理員關閉單一通知。

CancelNotification(String)

通知管理員關閉單一通知。

[Android.Runtime.Register("cancelNotification", "(Ljava/lang/String;)V", "")]
public void CancelNotification (string? key);
[<Android.Runtime.Register("cancelNotification", "(Ljava/lang/String;)V", "")>]
member this.CancelNotification : string -> unit

參數

key
String

要從 關閉的 StatusBarNotification#getKey()通知。

屬性

備註

通知管理員關閉單一通知。

如果您的接聽程式有允許使用者關閉個別通知的使用者介面,請使用這個介面,類似於 Android 狀態列和通知面板的行為。 當使用者使用 UI 關閉單一通知之後,應該呼叫它;收到通知后,通知管理員實際上會移除通知,而您會收到回 #onNotificationRemoved(StatusBarNotification) 呼。

<b>注意:</b> 如果您的接聽程式允許使用者點選/按兩下/等來引發通知android.app.Notification#contentIntent,則當有問題的通知已android.app.Notification#FLAG_AUTO_CANCEL設定旗標時,您應該在該時間呼叫此方法。

服務應該先等候事件, #onListenerConnected() 再執行這項作業。

android.service.notification.NotificationListenerService.cancelNotification(java.lang.String)Java 檔。

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於

CancelNotification(String, String, Int32)

警告

deprecated

通知管理員關閉單一通知。

[Android.Runtime.Register("cancelNotification", "(Ljava/lang/String;Ljava/lang/String;I)V", "")]
[System.Obsolete("deprecated")]
public void CancelNotification (string? pkg, string? tag, int id);
[<Android.Runtime.Register("cancelNotification", "(Ljava/lang/String;Ljava/lang/String;I)V", "")>]
[<System.Obsolete("deprecated")>]
member this.CancelNotification : string * string * int -> unit

參數

pkg
String

通知應用程式的套件。

tag
String

通知應用程式在 中指定的 android.app.NotificationManager#notify(String, int, android.app.Notification)通知標記。

id
Int32

中通知應用程式 android.app.NotificationManager#notify(String, int, android.app.Notification)所指定的通知標識碼。 <p>

屬性

備註

通知管理員關閉單一通知。

如果您的接聽程式有允許使用者關閉個別通知的使用者介面,請使用這個介面,類似於 Android 狀態列和通知面板的行為。 當使用者使用 UI 關閉單一通知之後,應該呼叫它;收到通知后,通知管理員實際上會移除通知,而您會收到回 #onNotificationRemoved(StatusBarNotification) 呼。

<b>注意:</b> 如果您的接聽程式允許使用者點選/按兩下/等來引發通知android.app.Notification#contentIntent,則當有問題的通知已android.app.Notification#FLAG_AUTO_CANCEL設定旗標時,您應該在該時間呼叫此方法。

服務應該先等候事件, #onListenerConnected() 再執行這項作業。

已取代這個成員。 請改用 #cancelNotification(String key)android.os.Build.VERSION_CODES#LOLLIPOP從這個方法開始,將不再取消通知。 它會繼續取消早於android.os.Build.VERSION_CODES#LOLLIPOP的應用程式targetSdkVersion通知。

android.service.notification.NotificationListenerService.cancelNotification(java.lang.String, java.lang.String, int)Java 檔。

此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。

適用於