How can I dynamically change the notification message when combining multiple notifications in Android?

I am trying to accomplish this simple task regarding push notifications in Android (C2DM):

  • If the notification bar does not exist, set it to "foo A"
  • If the notification already exists, take it, read its text and then update it to "N notifications: foo, bar, ...". This is similar to what the Gmail client will do on Android when you receive 1 email against several.

I looked through the documents, read http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating , searched for SO and the Internet, but so far I don’t see a way to access the notification in the notification panel.

Do I need to manage the account elsewhere and have it reset when the user rejects the notification? Is there no way to read an existing one?

Thank.

+3
source share
1 answer

if the notification already exists, take it, read its text and then update it to "N notifications: foo, bar, ...". This is similar to what the Gmail client will do on Android when you receive 1 email in a few.

No, it is not. Gmail already has this information in the database. He does not need to "capture [notice], read its text."

In addition, what you want is impossible.

Do I need to manage the counter elsewhere and have it reset when the user rejects the notification?

Yes.

Is there no way to read an existing one?

.

0

Source: https://habr.com/ru/post/1791348/


All Articles