AlarmManager应该每隔1分钟重复一次,但每1,2,3或4分钟重复一次。设置重复AlarmManager在指定的时间内没有响应
由于应用我扔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);
}
}
由于广播接收器调用IntentService。
public class GpsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent gps = new Intent(context, GpsIntentService.class);
context.startService(gps);
}
}
而且intentservice执行任务
public class GpsIntentService extends IntentService {
public GpsIntentService() {
super("GpsIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
System.out.println("Intent service ejecutado");
}
}
当这种情况发生的背景,我有一对夫妇在前台运行活动。
您如何测量广播接收器或意图服务中的这个?如果在意向服务中,如果有任何事情导致服务运行很长,则会阻止下一次启动。 –
我测量logcat中的打印时间,从intentservice发送打印。 – manduinca
从接收器来衡量,让我们试着消除潜在的问题来源。如果每分钟拨打一次接收者,问题出在您的服务上。如果不是,那么它与警报。 –