KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am adding some basic alarm functionality to my program via the use of AlarmManager and a BroadcastReceiver class (named AReceiver.java). My problem is that the data I add to the bundle attached to the Intent creating the PendingIntent appears to be lost. The only bundle data I can access in the AReceiver class is a android.intent.extra.ALARM_COUNT=1. Here is the basic code in the main activity class creating the Intent, PendingIntent and the AlarmManager: [Code in main activity - Notepadv3] Intent intent = new Intent(Notepadv3.this, AReceiver.class); intent.putExtra("teststring","hello, passed string in Extra"); PendingIntent alarmIntent = PendingIntent.getBroadcast(this, pendingPeriodIntentId, intent, 0); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, timeOfNextPeriod.getTimeInMillis(), alarmIntent); [Code in the BroadcastReceiver - AReceiver] public void onReceive(Context con, Intent arg1) { Bundle extrasBundle = arg1.getExtras(); Log.d("broadcast","contains teststring = " + extrasBundle.containsKey("teststring")); Log.d("broadcast","is empty? = " + extrasBundle.isEmpty()); Log.d("broadcast","to string = " + extrasBundle.toString()); } Debug messages say that contains teststring is FALSE, is empty is FALSE and when outputting the whole bundle, I get the android.intent.extra.ALARM_COUNT=1 value. Any help would be greatly appreciated. Cheers, Tom
Tags (comma-separated)
Save Edits
Cancel