I have set an AlarmManagr with a repeat time. Here is my method by which I am setting it:
public void setAlarmManager(Context context, Intent intent) {
PendingIntent pendingIntent;
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
AlarmManager alarmManager =
(AlarmManager)context.getSystemService(context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, 10);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(),
40000, pendingIntent);
}
This works fine except when my device goes into sleep mode the the alarm stops working until I awake my device manually. After waking the device the AlarmManager start working again.
How to keep the manager running even in sleep mode?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…