警报管理器立即触发
Alarm Manager firing instantly
我知道这个问题已经被问过很多次了,也回答了很多次,我确实查看了很多帖子并尝试了所有的帖子,但有些问题我现在仍然遇到了问题。
我的代码是这样的:
cal = Calendar.getInstance();
cal.setTime(CalendarUtils.getDateFromString(objScheduleDO.ScheduleStartTime, CalendarUtils.TIME_FORMAT));
LogUtils.debug("Time",cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE));
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis() , pi);
我使用 RTC_WAKEUP 它会立即触发,如果我使用 ELAPSED_REALTIME_WAKEUP 它根本不会触发。
而且我确定开始时间永远不会是当前时间,它总是未来的时间。
TIME_FORMAT 是 "hh:mm aa"。而且我进一步验证了时间是正确的,但是当我试图通过调试获取cal.getTimeInMillis()时,我收到的是一个整数值而不是long,不确定Android Studio调试模式是否可以给long值与否。
请帮忙..
If the stated trigger time is in the past, the alarm will be triggered immediately.
确认您的日期没有过去。
我知道这个问题已经被问过很多次了,也回答了很多次,我确实查看了很多帖子并尝试了所有的帖子,但有些问题我现在仍然遇到了问题。
我的代码是这样的:
cal = Calendar.getInstance();
cal.setTime(CalendarUtils.getDateFromString(objScheduleDO.ScheduleStartTime, CalendarUtils.TIME_FORMAT));
LogUtils.debug("Time",cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE));
am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis() , pi);
我使用 RTC_WAKEUP 它会立即触发,如果我使用 ELAPSED_REALTIME_WAKEUP 它根本不会触发。
而且我确定开始时间永远不会是当前时间,它总是未来的时间。
TIME_FORMAT 是 "hh:mm aa"。而且我进一步验证了时间是正确的,但是当我试图通过调试获取cal.getTimeInMillis()时,我收到的是一个整数值而不是long,不确定Android Studio调试模式是否可以给long值与否。
请帮忙..
If the stated trigger time is in the past, the alarm will be triggered immediately.
确认您的日期没有过去。