gpt4 book ai didi

android - 如何在 android 中重复闹钟工作日

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:48:57 31 4
gpt4 key购买 nike

我只想在周一到周五收到闹钟。我的代码在这里

if (chk_weekday.isChecked()) {

int day = calNow.get(Calendar.DAY_OF_WEEK);
if (day == 2 || day == 3 || day == 4 || day == 5
|| day == 6) {

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
calSet.getTimeInMillis(), 1 * 60 * 60 * 1000,
pendingIntent);

}

有想法。

最佳答案

请尝试此代码。在我的应用程序中成功运行

if (chk_monday.isChecked()) {
forday(2);
} else if (chk_tuesday.isChecked()) {
forday(3);
} else if (chk_wednesday.isChecked()) {
forday(4);
} else if (chk_thursday.isChecked()) {
forday(5);
} else if (chk_friday.isChecked()) {
forday(6);
} else if (chk_sat.isChecked()) {
forday(7);
} else if (chk_sunday.isChecked()) {
forday(1);
}

public void forday(int week) {

calSet.set(Calendar.DAY_OF_WEEK, week);
calSet.set(Calendar.HOUR_OF_DAY, hour);
calSet.set(Calendar.MINUTE, minuts);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
calSet.getTimeInMillis(), 1 * 60 * 60 * 1000, pendingIntent);
}

关于android - 如何在 android 中重复闹钟工作日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12507901/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com