I don\'t understand what\'s wrong but my alarm runs every single day even if I hardcode the day number, I have no idea whats going on...
Intent notificationInten
Why is this line necessary?
calendar.setTimeInMillis(System.currentTimeMillis());
Also, the android development documentation recommends using
setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation);
EDIT: I suspect the intent isn't set for creating alarms so it's not creating the alarms correctly. Maybe this would work:
Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
//set repeating alarm here
I hope that answers the question.
So okay i have solved this , for everyone who want to create an alarm application like this > you set the time and hour and the days of week to trigger the alarm, it works like this : if today is the day which you choosed you just set the alarm with this :
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
but IF the day you picked is not the day which is today you have to the the date of the nearest day you picked and then just set the additional hour and minute as above.
this is the only way to make it work