我设置了每天重复的报警。 但它会有几秒或几分钟的错误。 我怎样才能让它更准确?每天准确地重复报警(报警管理器)
PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), notificationId, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(Context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 12);
calendar.set(Calendar.MINUTE, 30);
long startUpTime = calendar.getTimeInMillis();
if (System.currentTimeMillis() > startUpTime) {
startUpTime = startUpTime + 24*60*60*1000;
}
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, startUpTime, 24*60*60*1000 , pendingIntent);
是否'myIntent'指向一个'WakefulBroadc astReceiver'? – CommonsWare