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. how to change location provider provider...

i have developed an app which just notify when location changed...
it used GPS_PROVIDERS as provider..
but as devices go inside of some building. it stop listening ..
i want to change the provider at that time to network provider..
so should i write locationManager.requestLocationUpdate method there in
status change method of listener.with provider to network provider...
or something else will do the task...


 A N K ! T......


2. Android Canvas.getMatrix followed by Canvas.setMatrix(null) raises NullPointerException

In the lunar lander example, if I add the following two lines to the
top of the doDraw method, the app crashes immediately with a

Matrix m = canvas.getMatrix();
canvas.setMatrix( null );

Stack trace is:
    at android.view.Surface$CompatibleCanvas.setMatrix(

The canvas documentation for setMatrix states that "If the matrix
parameter is null, then the current matrix is reset to identity", so
there's no reason this should crash.

Also, if I do not call getMatrix before calling setMatrix(null), then
setMatrix(null) is successful.  So it would seem that it is the
combination of the two calls that are causing a problem.

Whats going on here?


3. Problem in running test case

4. Help!!! Unknown Error - java.lang.NullPointerException :: Android Packaging Problem

5. SDK Add-on for Samsung Galaxy Tab

6. Galaxy Tab SDK missing shared library

7. Crash report: NoSuchFieldError