Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble sending Bundle with PendingIntent to a Broadcast Receiver, data lost
    primarykey
    data
    text
    <p>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.</p> <p>Here is the basic code in the main activity class creating the Intent, PendingIntent and the AlarmManager: [Code in main activity - Notepadv3]</p> <pre><code>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></pre> <p>[Code in the BroadcastReceiver - AReceiver]</p> <pre><code>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()); } </code></pre> <p>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.</p> <p>Any help would be greatly appreciated.</p> <p>Cheers, Tom</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload