Intent.getIntExtra doesn't find value

by kaloer » Sun, 15 Nov 2009 05:39:47 GMT

Sponsored Links

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

                Intent intent = new Intent(ALARM_ALERT_ACTION);
                if (Log.LOGV)
                        Log.v("** setAlert id " + id + " atTime " + 
                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);
                intent.putExtra(Alarms.SNOOZE_DURATION, snoozeDuration);
                PendingIntent sender = PendingIntent.getBroadcast(context, 0,

                if (true) {
                        am.set(AlarmManager.RTC_WAKEUP, atTimeInMillis, sender);
                } else {
                        // a five-second alarm, for testing
System.currentTimeMillis() + 5000,

                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 i = getIntent();
        mAlarmId = i.getIntExtra(Alarms.ID, -1);
        mDismissBehaviour = i.getIntExtra(Alarms.DISMISS_BEHAVIOUR,
        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!



Other Threads

1. I formed preference using XML, but I don't know how can I open other view using XML tag intent...

Hi, all.

I formed preference view using XML codes..
in here, I wonder that how can I show other View at click this item
using <intent> tag.

if not available, could you give me some advice about this...
I want to implement using XML tag


            android:data="" />


2. Which process is responsible for injecting KeyEvents to the system ?

Hi all:
      This happened When i tryed to send keyevents repeatly: After a
period of time (may be 2h or more) , I started to get
RemoteExceptions. obviously, the process hadling keyevents is
dead ,But i'm not sure which process is,Could anyone tell me ?
     And, how i could avoid this happen ? Or,how could i recover the
system after this error(maybe just killing the Process is ok?)
    Thanks in advance !


3. migrating 1.5_pre -> 1.5_r1

4. Multiple shapes on one Drawable

5. Make an Alert for a background process

6. Initial database population from large data files, several problems

7. android startup problem after moving from SDK-1.0 to 1.5