[英]AlarmManager not firing on next day
i have set AlarmManager for particular time and updating time when older one is fired . 我已将AlarmManager设置为特定时间,并在解雇了较旧的对象时更新时间。 but problem is AlarmManager is not firing on next date but if i change date manually then its working but if automatically changes then it not firing
但是问题是AlarmManager在下一个日期不触发,但是如果我手动更改日期,则它的工作状态,但是如果自动更改,则不触发
AlarmManager alarm = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
Intent intent = new Intent(context, BrSendSMS.class);
intent.putExtra("schedulesmsid", schedulesmsid);
int schedulelistid = -1;
try
{
schedulelistid = Integer.valueOf(schedulesmsid);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, schedulelistid, intent, Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
alarm.cancel(pendingIntent);
alarm.set(AlarmManager.RTC_WAKEUP, scheduledtime, pendingIntent);
} catch (NumberFormatException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
Try to use setRepeating... 尝试使用setRepeating ...
use the code below... 使用下面的代码...
Calendar alarmTime=Calendar.getInstance();
alarmTime.set(Calendar.HOUR_OF_DAY,18);
alarmTime.set(Calendar.MINUTE, 0);
alarmTime.set(Calendar.SECOND, 0);
Intent alarmIntent = new Intent(MainActivity.this,AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, alarmIntent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Long time = alarmTime.getTimeInMillis() + (24 * 60 * 60 * 1000 * 2);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, time,24 * 60 * 60 * 1000 * 2, pendingIntent);
i hope it will help for you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.