intent.putExtra() in pending intent not working

后端 未结 5 716
你的背包
你的背包 2021-02-02 08:25

I am passing a pending intent through alarmreceiver, from a service class. But, after the pendingIntent fires, the intent.putExtra() information is not being received by the bro

5条回答
  •  孤独总比滥情好
    2021-02-02 08:51

    Try this

    Intent aint = new Intent(getApplicationContext(), AlarmReceiver.class);
    aint.putExtra("msg", msg);
    aint.putExtra("phone", phone);
    
    
    
    PendingIntent pendingIntent = PendingIntent.getBroadcast(
        getApplicationContext(),
        id, 
        aint,
        // as stated in the comments, this flag is important!
        PendingIntent.FLAG_UPDATE_CURRENT);
    

提交回复
热议问题