Display notification at a specific time

103 Views Asked by At

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
                }
           }
1

There are 1 best solutions below

1
jc4life87 On

Recommend you learn about event listeners and check out the stack answer below:

Current time/date event listener