Calendar calendar = Calendar.getInstance();
//set notification for date --> 8th January 2010 at 9:06:00 PM
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.YEAR, 2010);
calendar.set(Calendar.DAY_OF_MONTH, 8);
calendar.set(Calendar.HOUR_OF_DAY, 21);
calendar.set(Calendar.MINUTE, 06);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.AM_PM,Calendar.PM);
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, alarmIntent);
// Enable {@code SampleBootReceiver} to automatically restart the alarm when the
// device is rebooted.
ComponentName receiver = new ComponentName(context, SampleBootReceiver.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(receiver,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
这是我的主要活动代码,我希望它每年1月8日触发推送通知,或者可能是用户的生日,但它每天触发此推送通知,因为我已提到" AlarmManager.INTERVAL_DAY"。但是如何让它每年都有效,就像它应该只触发用户生日的推送通知一样。
谢谢