0

I always get bundle value null when I pass data from activity to broadcast receiver. My receiver will start on boot up.

This is the code in my activity class

Intent intent= new Intent();
intent.setAction("android.intent.action.BOOT_COMPLETED");
intent.putExtra("test", "test");    
sendBroadcast(intent);

This is the code in my receiver class:

String testValue = intent.getStringExtra("test");
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1810931
  • 638
  • 2
  • 11
  • 33

1 Answers1

0

Your code in activity will never be called upon booting up. System invokes onReceive() with its own intent. You can check this by putting some logs in activity code - this log will not be printed in logcat.

tundundun
  • 634
  • 1
  • 5
  • 12