Reputation: 1052
I want to schedule my service to update some data, I need it to be scheduled on boot^ but if user launches my app at first, I would like to schedule my service too. I want to use AlarmManager fo this. Is there way to recognize, is my service has been already scheduled?
Upvotes: 0
Views: 165
Reputation: 39397
Use AlarmManager.cancel() to cancel your previously scheduled service (it won't do anything if nothing was actually scheduled, so you can call it anyway) and then schedule your service as you would normally do
Upvotes: 1
Reputation: 4897
Just catch the ACTION_BOOT_COMPLETED intent and do your registration then. Not in onCreate().
Upvotes: 0