2013-10-26 32 views
0

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

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这是以毫秒为单位的日期还是从现在到那个时间之间的毫秒数? “

回答

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); 
0

”使用适当的时钟(取决于报警类型)报警应该停止的时间(以毫秒为单位)“。

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

This教程可能会帮助你。