mardi 9 février 2021

Android Studio - Notification for specific time

I have currently created a notification which displays no problem when the switch is checked, however I want to create an if statement to set a current time of when the notification will be displayed. I have tried the below however the notification doesn't display at the 3:30pm when tested, am I missing anything or how can I do this?

  public void onCheckedChanged(CompoundButton buttonView, boolean notificationSwitchisChecked) {
  if(notificationSwitchisChecked){
       Calendar.getInstance();
       if (Calendar.HOUR_OF_DAY == 15 && Calendar.MINUTE == 30 && Calendar.SECOND == 0){
         sendNotification(); // this method displays the notification no problem when checked
            }
       }

Aucun commentaire:

Enregistrer un commentaire