intent.putExtra() in pending intent not working

后端 未结 5 714
你的背包
你的背包 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 09:01

     final Intent my_intent = new Intent(this.context , Alarm_Receiver.class);
    
        //put in extra string into my intent
        //tell the clock that the user pressed the "alarm on button"
        my_intent.putExtra("extra" , 1);
        int state = my_intent.getExtras().getInt("extra");
        Log.i("extraa" , "the state in the main activity in alarm on Button is: " + state);

    I had the same problem and I found out that you should put the putExtra before you involve the Intent

提交回复
热议问题