2
我有一个在后台运行的服务。我正在使用报警管理器启动此服务。它工作正常,但是当我在设备或模拟器中更改系统时钟时,警报管理器停止。更改系统时钟时停止报警管理器
public void startAzanService() {
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(this, CheckAzan.class);
PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
//repeat the action every 5 secionde
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 5000, pintent);
}
我害怕,我不得不说,逻辑看起来不好。 – Farhan