问题
So I've noticed on my android device (Marshmallow) that a new email (Gmail) notification goes away if I view the new email in my desktop. Same goes for WhatsApp messages. I was just wondering how this is implemented.
Obviously tried Googling this, but all I found was on Clearing the notifications or disabling them.
回答1:
The application is calling a servlet to see if there are any new/unread messages via a background service. When you view the message on your PC, the service is updated with how there are no longer any unread messages. With this update, the background service in the app sees that there are not any unread messages, so it cancels the notification by its ID with the NotificationManager.
来源:https://stackoverflow.com/questions/38464684/notification-on-android-device-disappears