Reputation: 23
I have a AlarmManager that run at the 20:00, but also run when i click the button for fix it. I only want that run at the 20:00
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 20);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
AlarmManager a = (AlarmManager)getSystemService(ALARM_SERVICE);
a.setRepeating(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(),AlarmManager.INTERVAL_DAY,p);
Upvotes: 0
Views: 216
Reputation: 590
Put Below code in your code for repeating alarm at specific time
if(System.currentTimeMillis() <= c.getTimeInMillis()){
AlarmManager a = (AlarmManager)getSystemService(ALARM_SERVICE);
a.setRepeating(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(),AlarmManager.INTERVAL_DAY,p);
}
i hope it helps you...
Upvotes: 1