- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用 AlarmManager.AlarmClockInfo
设置闹钟。
此构造函数需要时间和 PendingIntent
,在文档中描述为:
an intent that can be used to show or edit details of the alarm clock.
然后 setAlarmClock( )
也接受了一个未决的 Intent ,它在文档中被描述为:
Action to perform when the alarm goes off
我了解 setAlarmClock( )
使用 PendingIntent
,但是 AlarmClockInfo
如何使用 PendingIntent
code> 以及如何使用它来编辑闹钟的详细信息?
最佳答案
however, how is the PendingIntent used by AlarmClockInfo and how do I use it to edit the details of the alarm clock?
引用自 this book :
The biggest issue with
setAlarmClock()
is that it is visible to the user:
The user will see the alarm clock icon in their status bar, as if they had set an alarm with their device's built-in alarm clock app
The user will see the time of the alarm when they fully slide open their notification shade
- Tapping on the alarm time in the notification shade will invoke the
PendingIntent
that you put into theAlarmClockInfo
object
所以,给定这段代码......:
static void scheduleAlarms(Context ctxt) {
AlarmManager mgr=
(AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(ctxt, PollReceiver.class);
PendingIntent pi=PendingIntent.getBroadcast(ctxt, 0, i, 0);
Intent i2=new Intent(ctxt, EventDemoActivity.class);
PendingIntent pi2=PendingIntent.getActivity(ctxt, 0, i2, 0);
AlarmManager.AlarmClockInfo ac=
new AlarmManager.AlarmClockInfo(System.currentTimeMillis()+PERIOD,
pi2);
mgr.setAlarmClock(ac, pi);
}
(来自 this sample project)
...当用户点击通知栏中的时间时,EventDemoActivity
将出现。我们的想法是,您应该在此处提供允许用户取消或重新安排此警报的 Activity 。
关于android - AlarmManager.AlarmClockInfo 的 PendingIntent 是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34699662/
问题 当我尝试将 AlarmManager.AlarmClockInfo 对象用于 getNextAlarmClock() 时,我的应用程序抛出:Attempt to invoke virtual m
我正在尝试使用 AlarmManager.AlarmClockInfo 设置闹钟。 此构造函数需要时间和 PendingIntent,在文档中描述为: an intent that can be us
我是一名优秀的程序员,十分优秀!