I am developing an application where there are 3 buttons.Say,button_1 for 5 min, button_2 for 10 min , button_3 for 15 min.
when user clicks on one of the button,i set alarm for that time.I am using OneShotAlarm.class
as BroadcastReceiver for alarm.I put alarm_time(5,10 or 15 min) in intent to fire alarm like,
Intent alarm_intent = new Intent(context, OneShotAlarm.class);
alarm_intent.putExtra(SNOOZE_TIME, 5);
and I am trying to retrieve this in OneShotAlarm.class
,but somehow,it keeps on taking 5 there whatever I put into intent at the time of setting alarm.
Though alarm fires for all options correctly and at correct time,but I don't get the value properly in OnShotAlarm.class
from intent's Integer extra.
I use same alarm request code for all alarms,but creates new objects everytime for setting up alarm.This is,if it concerns.
Hope,I cleared the question enough.Please help me pointing out what I am missing?
EDIT :
I forgot to specify that these three buttons are in a widget and I use a broadvcast receiver to catch their clicks.Sorry for the inconvenience when you tried to put your effort to help me!
I was using these three buttons in widget.I forgot to specify that in my question,I am sorry!
There was no problem in my code,It was correct.But what I used to call the BroadcastReceiver for catching clicks of buttons of widget,was having a little problem.
I used these lines in my onUpdate() of WidgetProvider class,
receiver = new Intent(context, ClickCounterWidgetReceiver.class);
receiver.setAction("SET_SNOOZE");
receiver.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
pendingIntent = PendingIntent.getBroadcast(context, 0, receiver, 0);
changing the line to below one solved the issue:
pendingIntent = PendingIntent.getBroadcast(context, 0, receiver, PendingIntent.FLAG_UPDATE_CURRENT);