Android: Start a service on BOOTUP, and then schedule the service to run every 10 minutes?

advertisements

I would like to have a service run on bootup and then scheduled to run every 10 minutes.

Any ideas how i go about this?

If on bootup can i force a schedule for 10 minutes, but i presume i would need to schedule this everytime on bootup because after a reboot all schedules are lost?

Any help really appreciated

thanks


There's a nice little tutorial here that explains how to start a service at boot time that just keeps running and at some regular interval does something (writes to a log file, in the case of the tutorial).

As @CommonsWare points out, this creates an unnecessary load on the system. A better approach is to schedule a repeating alarm with AlarmManager, as described in this thread. You can register your app to receive the BOOT_COMPLETED broadcast (as described in the above tutorial) and in response schedule the alarm.