Reputation: 7411
In my app I have groups and for each group there can be updates which I am showing in notification. But in database I have group ids as string
. So for generating notification for each group, I need a unique int
id. So how can I transform string
ids to int
ids. So that there can be only 1 notification per group and the contents can be appended as there are updates in that specific group.
I have seen while displaying notifications I can supply tag
as well.
NotificationManager.notify(String tag, int id, Notification notification)
But for that I also need to supply int
id. So how this in combination works? Or any way I can rely only on the string
id of the notification?
Upvotes: 1
Views: 1194
Reputation: 376
Your (tag, id)
combination of notifications to be shown differently should be different. Otherwise the latest one will replace the previous one. So, here you can just use the string id
you have as tag
if it is unique and use any int id
as the combination must be unique.
Upvotes: 3
Reputation: 93589
You can use the hash of the string. Or you can use the tag for a string.
Upvotes: 2