0

我正在开发一个应用程序,当用户安排它们执行时,它必须运行某些任务。我不确定以下内容在 Android 文档中的含义。

triggerAtMillis: time in milliseconds that the alarm should go off, using the appropriate clock (depending on the alarm type)

set这是来自方法文档的引用。

例如,如果我希望任务在 27.10.2013 18:05 运行,我应该使用 1382810700000 (以毫秒为单位的日期)还是从现在到那个时间之间的时间(以毫秒为单位)?

4

2 回答 2

1

如果你想为你创建警报for example-27.10.2013 18:05 you can use try something like this :

Calendar cal = Calendar.getInstance();
cal.set(year, month, day, hourOfDay, minute, second);

报警服务:

AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal .getTimeInMillis(), pendingIntent);
于 2013-10-26T17:10:43.437 回答
0

“闹钟应该响起的时间(以毫秒为单位),使用适当的时钟(取决于闹钟类型)。”

这意味着您希望它运行的日期(小时分钟等)以毫秒为单位。

教程可能会对您有所帮助。

于 2013-10-26T17:02:28.303 回答