【发布时间】:2021-02-08 20:22:57
【问题描述】:
我目前创建了一个通知,当检查开关时显示没有问题,但是我想创建一个 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
}
}
【问题讨论】:
标签: java android-studio android-notifications android-calendar android-switch