I have 2 alarms set, one for notifications, and the other one to do some tasks. My problem is that only one alarm seems to work( the notifications service one, the first alarm set). The Other alarm never goes off. Here is my code :
Intent myIntent1 = new Intent(getApplicationContext(), NotificationService.class);
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, myIntent1, 0);
AlarmManager alarmManager1 = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
Calendar calendar1 = Calendar.getInstance();
calendar1.setTimeInMillis(System.currentTimeMillis());
long frequency1 = 30 * 1000; // in ms
alarmManager1.setRepeating(AlarmManager.RTC_WAKEUP, calendar1.getTimeInMillis(), frequency1, pendingIntent);
// Set alarm to fire go to Next day everyday at the same time
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 14); // For 1 PM or 2 PM
calendar.set(Calendar.MINUTE, 57);
calendar.setTimeInMillis(System.currentTimeMillis());
Intent myintent = new Intent(getApplicationContext(), AlarmNextDayService.class);
AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
PendingIntent pi = PendingIntent.getService(getApplicationContext(), 11, myintent,0 );
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pi);
Any suggestions are welcome. I have looked atother sources as well nothing works for me till now. I have also added alarm permisison in the manifest file as the following :
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
Thank you