Enabling & Disabling Alarm
I am developing one application for that I have created a AlarmReceiver file that receives alarm events.
There is a two Alarms in my app. Lets say one is starting a radio at particular time and other is stopping it.
The things are working fine but when the user disable and then re-enable the alarm the onReceive() method of AlarmReciever is getting called as and when user re-enable the alarm. :(
When a user clicks on disable alarm I simple store the current time which was set by the user previously. Later whenever the user comes and re-enable the alarm I just create a alarm with the previously stored time but the onReceive() method getting called instantlly.
How I disable the alarm:
Before disabling alarm I store the current value of Alarm.
AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
PendingIntent sender = = PendingIntent.getBroadcast(this, 1, intent, 0); // 1 for 1st alarm and 2 for 2nd alarm
I am not unregistering the BraodcastReciever as I don't know how to disable one receiver of AlarmReciever?
How I set bot the Alarm with unique alarm code...
alarmManager.setRepeating(AlarmManager.RTC, time, AlarmManager.INTERVAL_DAY, PendingIntent.getBroadcast(this, alarmUniqueCode, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT));
Please help! :)