我尝试使用setExact设置重复的AlarmManager。在活动中:
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, AlarmReceiver.class);
intent.setAction(ACTION_ALARM_RETRY);
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, 7000, sender);`
在我的行动之后接收器中我有:
public void onReceive(Context context, Intent intent){
//Here are my operations...
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
intent.setAction(ACTION_ALARM_RETRY);
PendingIntent sender = PendingIntent.getBroadcast(context, 1, intet, PendingIntent.FLAG_CANCEL_CURRENT);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, 7000, sender);
}
但它一直重复,没有最模糊的停顿...... 求救!