Set Repeat days of week alarm in android

后端 未结 4 1859
别跟我提以往
别跟我提以往 2020-12-12 23:08

Can somebody give good logic for set repeat days of week alarm? I have done weekly Alarm by using

            alarmCalendar.set(Calendar.HOUR, AlarmHrsInInt         


        
4条回答
  •  囚心锁ツ
    2020-12-12 23:48

    Intent intent1 = new Intent(getApplicationContext(),
                                NotificationReceiver.class);
    PendingIntent pendingIntent1 = PendingIntent.getBroadcast(getApplicationContext(),
                                                              1,
                                                              intent1,
                                                              PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager alarmManager1 = (AlarmManager)getSystemService(ALARM_SERVICE);
    java.util.Calendar calendar1 = java.util.Calendar.getInstance();
    
    calendar1.set(java.util.Calendar.DAY_OF_WEEK,
                  Calendar.MONDAY);
    calendar1.set(java.util.Calendar.HOUR_OF_DAY,
                  22);
    calendar1.set(java.util.Calendar.MINUTE,
                  8);
    calendar1.set(java.util.Calendar.SECOND,
                  0);
    
    alarmManager1.setExact(AlarmManager.RTC, calendar1.getTimeInMillis(), pendingIntent1);
    

提交回复
热议问题