Reputation: 683
Click the notification, service create a new activity, and activity create a new service?
My App MainActivity "OnCreate" create a service that is "sticky".
In my service, I post multiple notifications when there are some notices. The notice will be there unless user enters the app and reads the notice. There is a checking of new notice in onStartCommand.
Pressing the notification will send a intent to open the MainActivity.
There is Service, MainActivity and a notice.
After some time, MainActivity is killed by system.
Click the notification recreate the mainActivity. mainActivity start a "new?" service. The "new?" service create a new notification. So I am seeing multiple instants of same notice message. This is wrong. What is the correct way to handle this case?
Upvotes: 0
Views: 47
Reputation: 317
Quick fix: Before showing the notification, check whether or not the notification already exists there.
if(!notificationExists()){
showNotification;
}
Upvotes: 0