I encode a “simple” notifier, which consists of calling the website, checking the response, and notifying if something new.
I use the service to perform http operations, and I would like AlarmManager to redial the service call at a given frequency. I checked tutorials such as this and other examples, and since I want the service to be scheduled either whenever the user leaves the settings screen (only the activity that it has been so far) and after the BOOT is completed, so I created class for transferring the planning code.
public class Scheduler { public static boolean cancelScheduledService(Context ctx, Intent serviceIntent) { boolean success = true; Log.v("novUmbria", "Scheduler.cancelScheduledService"); try { AlarmManager am = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE); am.cancel( PendingIntent.getBroadcast( ctx, 0, new Intent(ctx, NotificadorService.class),
}
Here's a call to the scheduler from the Activity settings
Thing is: logcat tells me that the service is getting scheduled (or rather, that it does not throw an exception), and it starts the first time. But after that, no matter the long or short interval, it never repeats. I tried several flags RTC, RTC_WAKEUP, ELAPSED_REALTIME, etc., but I did not get anything.
My test device is completely updated by Nexus 4. I even rebooted it, so I checked that the BOOT_COMPLETE receiver is working fine, but it never repeats the service calls.
Any ideas on where the problem is?
Thanks in advance.