android - Performing a Scheduled task from a Service and Keeping that service Alive -


public class myhibernatedservice extends service{       public void oncreate() {         super.oncreate();         //declaring intents ..         //some codes...          alarmmanager = (alarmmanager)getsystemservice(alarm_service);         pendingintent pendingintent = pendingintent.getservice(this, 0, intentservicetoberun, 0);         calendar calendar = calendar.getinstance();         calendar.add(calendar.millisecond, 10000);           am.setrepeating(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), alarmmanager.interval_day, pendingintent);         } } 

i want service launch intentservice every single day @ time. however, i've read somewhere on internet, stackoverflow, google,etc.. service cannot stay alive forever, how android works. have kill service whenever android needs memory or using memory. guarantees me code run everyday , service not killed?

edit :

i noticed in android docs:

the android system attempt keep process hosting service around long service has been started or has clients bound it

what mean "clients bound it"?

don't use own service periodically start service, use alarmmanager service instead (like doing). there no need second service imho.

the alarmmanager system service , never killed android, , own service do: start things periodically (or single-shot @ specified time).

on "clients bound it": off-topic, means other components (like other services, or activities) connected using call context.bindservice(). details, check dev guide.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -