I have read about this AlarmManager
, but it's still a bit confusing to me.
So I have a Service
in my app, which I want to run all the time (its a medicinal app, so its supposed to notify the user the whole time its being used), but even though its a Service
, Android kills it from time to time, so I want to schedule it to be recreated in like 30mins interval, and then scheduled again. How can I do it?
For started services, there are two additional major modes of operation they can decide to run in, depending on the value they return from onStartCommand(): START_STICKY is used for services that are explicitly started and stopped as needed, while START_NOT_STICKY or START_REDELIVER_INTENT are used for services that should only remain running while processing any commands sent to them. See the linked documentation for more detail on the semantics.
http://developer.android.com/reference/android/app/Service.html