Reputation: 91
I have an sqlite db with a couple of events (e.g. concerts), that is updated 4 times a year. A few days before the event I want to notify the user for the concert. Now I don't know how to notify in an elegent way.
I found three possibilities:
The NotificationManager works, but I cannot schedule the alarms. The AlarmManager is for repeating alarms (thats not really what I want) and the Google Cloud Messaging Service is not the right tool I think, because I have the events with the dates already at the phone and don't want send a message via another server to notify. Maybe it is also possible to start a service, which calls the notification at the right time, but a lot of people uses app killers and then the notification will not work.
Has someone an idea?
Thank you, Stefan
Upvotes: 1
Views: 871
Reputation: 13705
I think the best way is AlarmManager, you said:
"is for repeating alarms (thats not really what I want)"
and that's not true, repeating alarms is just a feature of it, you can actually set an alarm once and forget about it, however, you need to come up with a mechanism to reset it after the device is rebooted, but this is true also for the "Service approach"
About the
"Maybe it is also possible to start a service, which calls the notification at the right time, but a lot of people uses app killers and then the notification will not work."
Well, if the app is killed either Service or any other background process approach will fail too because you are explicitly killing the process, also take on count that unnecessary running services are not recommended by Google specially if all you will do is a checking that another framework like AlarmManager does for you, so, there's no need to reinvent the wheel when you already have an AlarmManager well suited specifically for what you need, all you have to do is learning how to use it properly.
Regards!
Upvotes: 1
Reputation: 286
Another possibility is to ask the user if it's ok to make an event in their calendar app of choice. Goes well with the "integration" mindset. If the user permits it, you fire an appropriate intent. If not, they didn't want the notification anyway.
Upvotes: 0