闹钟提供者更改现有闹钟

huangapple 未分类评论51阅读模式
英文:

AlarmClock provider change existing alarm

问题

我正在使用AlarmClock内容提供程序来设置闹钟。

问题是,如果小时和分钟不同,它会每次都创建一个新的闹钟。
有没有一种方法可以简单地替换旧的闹钟?

我不想使用AlarmClock.ACTION_DISMISS_ALARM,因为它不适用于AlarmClock.EXTRA_SKIP_UI,并且会打开闹钟应用(有些甚至根本不支持它)。

有没有可能避免使用AlarmManager?

Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
intent.putExtra(AlarmClock.EXTRA_HOUR, hour);
intent.putExtra(AlarmClock.EXTRA_MINUTES, minute);
intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
intent.putExtra(AlarmClock.EXTRA_MESSAGE, "Some Alarm");

startActivity(intent);
英文:

I'm using the AlarmClock content provider to setup alarms.

The problem is that it creates a new alarm each time if the hours and minutes are not the same.
Is there a way to simply replace the old alarm?

I don't want to use AlarmClock.ACTION_DISMISS_ALARM because it doesn't work with AlarmClock.EXTRA_SKIP_UI and opens the alarm app (some even don't support it at all).

Is it possible to avoid AlarmManager?

Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
intent.putExtra(AlarmClock.EXTRA_HOUR, hour);
intent.putExtra(AlarmClock.EXTRA_MINUTES, minute);
intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
intent.putExtra(AlarmClock.EXTRA_MESSAGE, "Some Alarm");

startActivity(intent);

huangapple
  • 本文由 发表于 2020年4月10日 05:33:51
  • 转载请务必保留本文链接:https://java.coder-hub.com/61130574.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定