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.
Passing data from android activity to broadcast receiver on device boot up
-
18-03-2022 - |
Pergunta
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");
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow