3

I thought this would solve my problem, but it doesn't.

I have this code to send my alarm:

public void triggerAlarm() {
    AlarmManager alarmManager = (AlarmManager) getContext().getSystemService(ALARM_SERVICE);
    alarmManager = (AlarmManager) getContext().getSystemService(ALARM_SERVICE);
    Intent intent = new Intent(getContext(), AlarmReceiver.class);
    intent.putExtra("Id", nextDue.id.get() + "");
    String passed = intent.getStringExtra("Id");
    Log.d("DEBRRUG", "The extra im passing: " + passed);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(getContext(), i++, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    alarmManager.set(AlarmManager.RTC_WAKEUP, soonest.dueTime.get(), pendingIntent);
}

My DEBRRUG statement indicates that the extra being passed is 8.

This is my alarm receiver:

@Override
    public void onReceive(Context context, Intent intent) {
        String passed = intent.getStringExtra("Id");
        Log.d("DEBRRUG", "The extra im receiving: " + passed);
    }

Here, my DEBRRUG statemnt indicates that the extra im receiving is NULL.

Note: Something that could, possibly, be interesting is that my triggerAlarm method is being called from within my ContentProvider. Don't know if that helps you understand my problem better or not.

2 Answers2

1

Use intent.getExtras().getString("id")

chaitanya dalvi
  • 1,539
  • 2
  • 17
  • 25
0

I found it. Wow! I was sending another alarm in another area of my code, where I wasn't putting the extra on.

Doing ctrl f -> ".set(Alar" let me track down the little bastard.