Home:ALL Converter>Intent not passing data to BroadcastReceiver of AlarmManager

Intent not passing data to BroadcastReceiver of AlarmManager

Ask Time:2021-09-22T05:38:16         Author:user1922860

Json Formatter

I'm trying to pass data to BroadcastReceiver thru PendingIntent of AlarmManager

In the example I'm trying to pass a String and a Parcelable Object, however when I try to read them in the BroadcastReceiver I get null


AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent i = new Intent (this, ReminderBroadcast.class);
i.putExtra("ROUTINE", r);
i.putExtra("MESSAGE", "Example string");
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,1234,i,PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 10000, pendingIntent);


public class ReminderBroadcast extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
            Log.i(LOG_TAG,"notification code is "+ getResultCode());
            Log.i(LOG_TAG, "message is: "+ intent.getStringExtra("MESSAGE"));
            Log.i(LOG_TAG, "routine " + ((Routine)(intent.getParcelableExtra("ROUTINE"))).getRoutineName());


<activity android:name=".SetupNotificationActivity" />
<receiver android:name=".support.ReminderBroadcast" 
          android:enabled="true" />

This is driving me crazy, as all the solution found on the internet suggest to put PendingIntent.FLAG_UPDATE_CURRENT to solve the issue, but that seems not to work.

Any suggestion? Thanks

Author:user1922860,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275831/intent-not-passing-data-to-broadcastreceiver-of-alarmmanager