I want to have an android alarm manager to runs a service at the first day of every month. I have the folowing code:
PersianCalendar persianCalendar = new PersianCalendar();
persianCalendar.setTimeZone(TimeZone.getDefault());
if( persianCalendar.getPersianDay()==1){
Intent intent = new Intent(UsersActivity.this, AppsNetUsageReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC, persianCalendar.getTimeInMillis(), pendingIntent);
}
How can I guarantee my service runs successfully if the device was off or other reason prevent to my service do its work?