安卓的AlarmManager可不可以按照日期提醒?
我在写安卓备忘录,要加一个提醒功能,我现在用了安卓的AlarmManager,用Calendar来获得时间,但是AlarmManager并不会识别我设置的日期,只识别mi...
我在写安卓备忘录,要加一个提醒功能,我现在用了安卓的AlarmManager ,用Calendar来获得时间, 但是AlarmManager并不会识别我设置的日期,只识别minute 和 hour, 那我的提醒就只能提醒一天之内的啊。 求问,是安卓的闹钟服务就没有这个功能么?还是我写错了?
贴点代码
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, monthOfYear);
c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
public void onTimeSet(TimePicker view,
int hourOfDay, int minute) {
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
Intent intent = new Intent(SetAlarm.this, CallAlarm.class);
PendingIntent sender = PendingIntent.getBroadcast(
SetAlarm.this, 0, intent, 0);
AlarmManager am;
am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender); 展开
贴点代码
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, monthOfYear);
c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
public void onTimeSet(TimePicker view,
int hourOfDay, int minute) {
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
Intent intent = new Intent(SetAlarm.this, CallAlarm.class);
PendingIntent sender = PendingIntent.getBroadcast(
SetAlarm.this, 0, intent, 0);
AlarmManager am;
am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询