How to cancel a foreground service from using the notification (swipe dismiss) or clear all notifications?

后端 未结 6 1346
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 05:23

I\'m currently creating a foreground service with a notification that appears in the notification bar when the service starts. If the service stops, the notification dismiss

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 05:56

    I did the following and it worked for me:

    1. I created a notification before calling the foreground service with by same id and Notification Channel which are used with foreground service's notification

    2. I canceled the notification by the notification id

    3. I created another notification with your required structure

    4. You can dismiss or swipe this last notification without stop your foreground service

提交回复
热议问题