setRepeating of AlarmManager no responde dentro del tiempo indicado
AlarmManager debe repetirse cada 1 minuto, pero repetirse cada 1, 2, 3 o 4 minutos.
Desde la aplicación lanzo AlarmManager
public class PacienteApp extends Application {
@Override
public void onCreate() {
AlarmManager gps = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(this, GpsReceiver.class);
PendingIntent pending = PendingIntent.getBroadcast(this, 0, i, 0);
gps.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), 1000 * 60, pending);
}
}
Desde BroadcastReceiver llame a un IntentService.
public class GpsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent gps = new Intent(context, GpsIntentService.class);
context.startService(gps);
}
}
Y intentservice ejecuta la tarea
public class GpsIntentService extends IntentService {
public GpsIntentService() {
super("GpsIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
System.out.println("Intent service ejecutado");
}
}
Como esto ocurre en segundo plano, tengo un par de actividades ejecutándose en primer plano.