Send data to the alarm manager broadcast receiver

前端 未结 1 1809
悲哀的现实
悲哀的现实 2021-01-01 18:36

I am missing something here and I hope someone can help me out. I am setting up an alarm using the following:

    AlarmManager alarmManager = (AlarmManager)          


        
相关标签:
1条回答
  • 2021-01-01 19:22

    You need to add the extras to the Intent before you pass it to the PendingIntent:

    Intent broadcast_intent = new Intent(this, AlarmBroadcastReceiver.class);
    broadcast_intent.putExtra("test", "ValueReceived"); //data to pass
    
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,  broadcast_intent, 0);
    
    0 讨论(0)
提交回复
热议问题