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. Which Widget/UI Component to use for Gameboard?

If I want to create a gameboard, like a checker board or chess board,
and allow the user to select a square by tapping on it, which widget
should I use? The obvious approach would be to make each individual
square a button, but that sounds like too many objects.

Is there some sort of clickable-map widget I could use (not 'map' in
the sense of Google Maps, of course) to return the coordinates of
where he clicked, and let the programmer calculate which square that
is in? Should I just do the whole board as one View? Then what API do
I call to get the coordinates of the tap?


2. Android market clearly has to be full of piracy...oh well what can you do

Agreed Mark,

8 months of engineering and work, and so far a couple of weeks
advertising. I'm getting a news spread again in Computer Music
magazine, so that should increase visiblity for the new app too. My
wife says Im just not patient enough lol.

It's not the slow sales the bother me, it's just the strange download
numbers. The slow sales can be worked on with marketing efforts. The
download numbers though make we wonder what is going on behind the



3. WePad

4. Bad decision in twitter app

5. Re[2]: How to stop malicious market reviews?

6. Android market clearly has to be full of piracy...oh well what can you do

7. Fwd: How to debug