I have written a service that fetches data from a CRM based web service and puts in a database on the phone. Now this service has to be run every 3 hours, so it can sync data between CRM and the android database.
Now to have this service run itself, I'm using alarm manager and have the web service "start" itself.
Intent intent = new Intent(ServiceClass.this, ServiceClass.class);
PendingIntent pintent = PendingIntent.getService(ServiceClass.this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 10800*1000, pintent);
This service needs to be started after a reboot, for that purpose I'm using the method outlined here..
I just want to know if I'm going on the right path, or if I'm making a mistake or if there is a better way to do this. I haven't worked with Android much and just need a few pointers. Thanks!