Android Question Best Option for Notifications from a Service

devlei

Active Member
Licensed User
Longtime User
My App creates Notifications as reminders about tasks from a SQLite database that are about to start.

Currently I have a 'Sticky' Service running that checks when the next Notification is due and then use StartServiceAt to schedule when the service must run again. Every time a record is added or edited I also have to check that the StartServiceAt must not be changed. As it is my first attempt at Services/Notifications I am struggling to get it to work 100% accurately, and I was wondering if this is the best option.

Another option would be to have a Service that runs every 60 seconds and creates notifications that would be due in the next 60 seconds. A lot simpler, but not as precise!

Two questions:
1. Any recommendations as to the best option?
2. Would a Service that runs every 60 seconds use a lot of resources, and battery?
 

devlei

Active Member
Licensed User
Longtime User
Thanks for the recommendation, Erel. I am still getting inconsistent results and occasionally an "Unfortunately, myApp has stopped", so am trying to pinpoint where these are coming from.

1. Is it OK to use numerous StartServiceAt located in different Activity Modules to override a previous StartServiceAt?
2. I have one Sub that checks the database to set StartServiceAt and one Sub to post the Notification. Is it better to place these in the Service module or in an Activity module and then use CallSubDelayed from the Service? (I suspect some of the inconsistent behaviour is because currently I have these two Subs in the Service module and when the OS destroys the App there are initialisation issues)
 
Upvote 0
Top