Reputation: 127
I'm developing an app where users can create routines and set alarms and reminders for these routines. The current workflow that I have set up is:
My exact question is: Is this overkill?
A similar workflow is used when sending notifications. The broadcast receiver starts a foreground service that then creates a persistent notification. While the service is running although so briefly that it's not noticable it is displaying its own notification which gets removed when the service stops.
Did I overcomplicate things with the ForegroundService? Should all this work be done in the broadcast receiver?
Thanks for your help. Matic
Upvotes: 2
Views: 742
Reputation: 2471
This isn't an overkill if you need to actually use your own media player/vibrator and control their behavior instead of relying on those provided by the system notification channels (which come with limitations such as the inability to make useful changes after creation, sounds being cancelled by other notifications, users making accidental changes, etc).
Attempting to run media players/vibrators from the broadcast receiver in the background will run into background task limitations and result in all kinds of unpredictable issues.
I really wish Android made the notification channel APIs more flexible for developers. They don't have to sacrifice user control to achieve this at all.
Upvotes: 0