我目前创建了一个通知,在选中开关时显示没有问题,但是我想创建一个 if 语句来设置显示通知的当前时间。我已经尝试了以下方法,但是测试时在下午 3 点 30 分没有显示通知,我是否遗漏了什么或我该怎么做?
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
}
}