I am trying to use the alarm manager to trigger an alarm at a specific time every day. I am using this code
Intent intent = new Intent(AlarmSettings.this, AlarmService.class); intent.putExtra("i", i); PendingIntent mAlarmSender = PendingIntent.getService(AlarmSettings.this, Id, intent, 0); AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),Calendar.getInstance().getTimeInMillis()+(24*60*60*1000), mAlarmSender);}
the problem was if the cal.getTimeInMillis () value was started immediately in the past, I donโt know why, and when the cal.getTimeInMillis () value will work correctly in the future.
I need it to start at a specific time every day.
source share