Android Question Update dynamic icon from timer in background service

swabygw

Active Member
Licensed User
Longtime User
Many messaging apps now have a feature that the icon displays something like a small counter on the icon indicating that there are new messages, even when the app is closed. Additionally, the user can manually turn this service on/off.

I would like to recreate this functionality. My best guess is that there is a background service running with a Timer in it (similar to creating a Timer and Tick event in the Starter section) that routinely checks a remote server for unread messages and, given new messages, updates the icon (I'm guess that the service is either a Foreground or Stick service). And, the user has the option to turn this background service on or off.

Does anyone have an example of how to do something like this?
 

swabygw

Active Member
Licensed User
Longtime User
That's exactly what I was talking about. Considering the three ways of implementing a background service, as discussed here: https://www.b4x.com/android/forum/t...-long-running-background-tasks.27065/#content, I'm thinking of trying either the #2 (long-running, StartForeground solution) or #3 (Sticky, killed and recreated solution) type of background service, as both would get up-to-the-minute results, I believe. Do you recommend one over the other?
 
Upvote 0
Top