Intent.getIntExtra doesn't find value

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


Sponsored Links
 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

--



Other Threads

1. How to use a library in Android source and to write application on top of that

Hi All,

I have written a new library following  the given sample liberary in "/
development/sample/PlatformLibrary"

I have properly compiled it. It properly gets compiled without any
errors
it build binaries are vailable in below mentioned locations.

 ./symbols/system/lib/
./obj/lib/
Binary file ./obj/SHARED_LIBRARIES/native_lib_jni_intermediates/LINKED/
native_lib_jni.so matches
./obj/SHARED_LIBRARIES/native_lib_jni_intermediates/

But it is not available in "system.img"
When I copy all these img images to SDK and try to call these API in
my own application
It gives a error about the library namespace

Please guide me where to put this library in source code to get it
or is there any macro or setting by applying which we can get all
sample folder apps/libraries in system.img


Regards,
Arun
achoudhary2...@gmail.com
--~--~---------~--~----~------------~-------~--~----~

2. How to include library in source code and Applications

Hi All,

I have written a new library following  the given sample liberary in "/
development/sample/PlatformLibrary"

I have properly compiled it. It properly gets compiled without any
errors
it build binaries are vailable in below mentioned locations.

 ./symbols/system/lib/
./obj/lib/
Binary file ./obj/SHARED_LIBRARIES/native_lib_jni_intermediates/LINKED/
native_lib_jni.so matches
./obj/SHARED_LIBRARIES/native_lib_jni_intermediates/

But it is not available in "system.img"
When I copy all these img images to SDK and try to call these API in
my own application
It gives a error about the library namespace

Please guide me where to put this library in source code to get it
or is there any macro or setting by applying which we can get all
sample folder apps/libraries in system.img


Regards,
Arun
achoudhary2...@gmail.com
--~--~---------~--~----~------------~-------~--~----~

3. value @ "/sys/class/lightsensor/switch_cmd/lightsensor_file_cmd" is getting lost

4. oprofile usage with dalvik vm

5. Alternative SSL encryption algorithm

6. system_server SIGSEGV.

7. RIL and datacall (CSD)