Ongoing Notification Time Reset

surfuric

Member
Licensed User
Longtime User
I have a service which runs every hour using ServiceStartAt(...). I bring it to the foreground while it is working with StartForeground, then when it is finished I issue a StopForeground. I think this is working as planned.

However, when it is running, for some reason the time in the Ongoing notifications is actually the time the service started the very first time. Is there a way to change that to the last time the StartForeground was issued? Or maybe I am not using ServiceStartAt properly? Or do I need to destroy the service when I am finished (I do not know if the ServiceStartAt will reschedule if I do that.)

It just looks confusing when it is 10am and the ongoing notification says 7am (which is when I first started the service in this case).

Thanks,
Craig
 

surfuric

Member
Licensed User
Longtime User
Will StopService remove my ServiceStartAt from the queue?

Yes I do.
The sequence of events is:
ServiceStartAt (for the next hour)
StartForeground
...dosomework...
StopForeground

Each hour the ongoing notification pops up while in Foreground (but with the hour of when the service started originally, not this round), then dissapears when it completes with StopForeground.

To reset the time, I put StopService("") after StopForeground, this stops the service, and the next iteration the time is correct.

BUT . . . is this OK to call StopService each hour? That will not somehow undo my StartServiceAt scheduling will it?

If this is bad programming practice, or there is a better way, please let me know,
Craig
 
Upvote 0
Top