簡體   English   中英

當系統或用戶以外的其他任何人取消通知時,執行操作

[英]Perform an action when a notification is canceled by the system or anything else but the user

當系統(通過關閉或重新啟動)或除用戶以外的其他任何東西取消通知時,是否有辦法執行操作?

如果是這樣,怎么辦? 或如何實現onNotificationRemoved

您是否嘗試過NotificationListenerService

當發布或刪除新通知或更改其排名時,該服務會接收來自系統的呼叫。

要擴展此類,您必須使用BIND_NOTIFICATION_LISTENER_SERVICE權限在清單文件中聲明服務,並在SERVICE_INTERFACE操作中包含意圖過濾器。

<service android:name=".NotificationListener"
          android:label="@string/service_name"
          android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
     <intent-filter>
         <action android:name="android.service.notification.NotificationListenerService" />
     </intent-filter>
 </service>

現在,在您的Notification Listner類中,實現onNotificationRemoved

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM