Hi,
I'm modifying the default Alarm Clock application source, but I have a
problem sending an Integer value with an Intent. This is where I put
the "snooze_duration" value into the Intent:
static void enableAlert(Context context, int id, String label,
long atTimeInMillis, int dismissBehaviour, int
snoozeBehaviour, int
snoozeDuration) {
AlarmManager am = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(ALARM_ALERT_ACTION);
if (Log.LOGV)
Log.v("** setAlert id " + id + " atTime " +
atTimeInMillis);
intent.putExtra(Alarms.ID, id);
intent.putExtra(Alarms.LABEL, label);
intent.putExtra(Alarms.TIME, atTimeInMillis);
intent.putExtra(Alarms.DISMISS_BEHAVIOUR, dismissBehaviour);
intent.putExtra(Alarms.SNOOZE_BEHAVIOUR, snoozeBehaviour);
//HERE:
intent.putExtra(Alarms.SNOOZE_DURATION, snoozeDuration);
PendingIntent sender = PendingIntent.getBroadcast(context, 0,
intent,
PendingIntent.FLAG_CANCEL_CURRENT);
if (true) {
am.set(AlarmManager.RTC_WAKEUP, atTimeInMillis, sender);
} else {
// a five-second alarm, for testing
am.set(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + 5000,
sender);
}
setStatusBarIcon(context, true);
Calendar c = Calendar.getInstance();
c.setTime(new java.util.Date(atTimeInMillis));
String timeString = formatDayAndTime(context, c);
saveNextAlarm(context, timeString);
}
But when I try reading it, it sets the defaultValue instead. The other
values works as they should, but the snooze_duration doesn't. I get
the values in the OnCreate() method in the activity started by the
Intent:
Intent i = getIntent();
mAlarmId = i.getIntExtra(Alarms.ID, -1);
mDismissBehaviour = i.getIntExtra(Alarms.DISMISS_BEHAVIOUR,
0);
mSnoozeBehaviour = i.getIntExtra(Alarms.SNOOZE_BEHAVIOUR, 0);
mSnoozeDuration = i.getIntExtra(Alarms.SNOOZE_DURATION, 10);
Why doesn't this work? I have tried debugging, and it does put the
correct integer value in the Intent.putExtra method.
Thank you very much!
//Kaloer
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en