2
我使用下面的代碼本地通知每個月的Android
AlarmManager service = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(this, AlarmReceiver.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pending = PendingIntent.getBroadcast(this, 0, i,PendingIntent.FLAG_CANCEL_CURRENT);
Calendar cal = Calendar.getInstance();
// Start 30 seconds after boot completed
cal.add(Calendar.SECOND, 30);
//
// Fetch every 30 seconds
// InexactRepeating allows Android to optimize the energy consumption
service.setInexactRepeating(AlarmManager.RTC_WAKEUP ,cal.getTimeInMillis(),AlarmManager.INTERVAL_DAY , pending);
// service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
// REPEAT_TIME, pending);
在我的代碼我希望它工作一天的時間間隔後,並不會爲AlarmReceiver服務的廣播。
但是我想在一個月後發生這種情況。 E,g如果一個人在1月3日安裝應用程序,則下一次警報將在2月3日發生,依此類推。我怎麼能把一個月的時間間隔。
1個月完成什麼,如果用戶喜歡重新開始他的手機每隔15天 –
有設備重啓和報警之間沒有聯繫......所以它會工作。 – itsrajesh4uguys