Android - Alarm manager runs every day

前端 未结 2 1196
無奈伤痛
無奈伤痛 2021-01-25 01:21

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         


        
2条回答
  •  不知归路
    2021-01-25 01:50

    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

提交回复
热议问题