设置在某些日子的Android报警经理 [英] Setting android alarm manager on certain days
问题描述
我要建一个使用报警管理器的应用程序。用户设置日期和时间,并有7 checkboxs,一为一周的每一天,他们勾选报警将他们日子熄灭的人。就像我知道你可以把日期和时间到报警经理是有什么办法可以让像日期和时间到报警经理,他们将在这一天每个星期去了吗?
<一个href="http://developer.android.com/reference/android/app/AlarmManager.html#setRepeating%28int,%20long,%20long,%20android.app.PendingIntent%29">AlarmManager.setRepeating需要作为参数:
键入一ELAPSED_REALTIME,ELAPSED_REALTIME_WAKEUP},RTC或RTC_WAKEUP的。
在这里,你会想RTC或RTC_WAKEUP
triggerAtTime 时间报警应先熄灭,使用适当的时钟(取决于报警类型)。
在这里你给第一个警报(我相信这一定是UTC时间,所以一定要小心)
的日期/时间 台历挂历=新的GregorianCalendar(2011,Calendar.APRIL,19,23,12);
长firstTime = calendar.getTimeInMillis();
间隔报警后续重复的间隔时间。
要重复每个星期,你会给毫秒的整整一个星期的时间间隔数:
长间隔= 1000 * 60 * 60 * 24 * 7;
或
长间隔= 7 * AlarmManager.INTERVAL_DAY;
I'm building an app that uses alarm manager. The user sets day and time and there is 7 checkboxs, one for each day of the week and the ones they tick the alarm will go off on them days. Like i know you can put date and time into the alarm manager is there any way i can put like day and time into alarm manager and them it will go off on that day every week?
AlarmManager.setRepeating takes as parameter:
type One of ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP}, RTC or RTC_WAKEUP.
Here you will want RTC or RTC_WAKEUP
triggerAtTime Time the alarm should first go off, using the appropriate clock (depending on the alarm type).
Here you give the date/time of the first alarm (I believe this must be UTC time, so be careful)
Calendar calendar = new GregorianCalendar(2011, Calendar.APRIL, 19, 23, 12);
long firstTime = calendar.getTimeInMillis();
interval Interval between subsequent repeats of the alarm.
To repeat every week, you will give as interval the number of milliseconds in a whole week:
long interval = 1000 * 60 * 60 * 24 * 7;
or
long interval = 7 * AlarmManager.INTERVAL_DAY;
这篇关于设置在某些日子的Android报警经理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!