i want to make a simple alarm clock and i need to implement alarm manager into it, the user marks checkboxes which days he wants to repeat the alarm and he sets time and then i just get the numbers of days in week and do the following :
private AlarmManager alarmMgr;
private PendingIntent alarmIntent;
alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.DAY_OF_WEEK, day);
alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY * 7, alarmIntent);
the alarm fires right after setting it , i spent 3 weeks finding a solution how to make a simple working alarm but i cant figure it out. i heard that if the day you choose is today then you dont need to set the day of week to calendar object and if the day is not today then i have to find the date of the nearest incoming DAY chosen by user. right?