gpt4 book ai didi

java - 出现 "snoozing"警报问题

转载 作者:太空宇宙 更新时间:2023-11-04 11:40:03 24 4
gpt4 key购买 nike

有人知道如何执行贪睡功能以及我哪里出错了吗?

我的默认小睡时间是 5 分钟。在重新启动之前一切正常
应用程序然后不再工作。如果我清除缓存和数据,它会再次工作。

 public void onClick(View view) {

SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
int iSnoozeLeft = settings.getInt(PuzzleAlarm.SNOOZE_LEFT, 1);
if (iSnoozeLeft != 0) {
Intent activate = new Intent(AlarmNotification.this, AlarmReceiver.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(AlarmNotification.this, 0, activate, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

int iMinutes = Preferences.getSnooze(settings, AlarmNotification.this);
Calendar calendar = Calendar.getInstance();
calendar.roll(Calendar.MINUTE, iMinutes);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), alarmIntent);

SharedPreferences.Editor editor = settings.edit();
editor.putInt(PuzzleAlarm.SNOOZE_LEFT, iSnoozeLeft - 1); // disabling
// Commit the edits!
editor.commit();
}`

最佳答案

PendingIntent.getBroadcast(AlarmNotification.this, 0, activate, 0);

确保您没有使用“0”作为其他警报 ID。在其他情况下,您的“贪睡”代码将覆盖之前的闹钟。

关于java - 出现 "snoozing"警报问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42903498/

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