As title, I am wondering under what situation we must register the BroadcastReceiver dynamically in an Activity? Can somebody give me some scenarios the statically registered receivers cannot fulfill?
Thanks:)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In addition to @Pedro Loureiro’s scenario, certain system broadcasts (e.g.,
ACTION_BATTERY_CHANGED,ACTION_SCREEN_OFF,ACTION_SCREEN_ON) can only be received by dynamically-registered broadcast receivers.Also, there will be patterns where you will register dynamically for a broadcast to be sent from your own service, such as the activity-or-
Notificationscenario I outline in this blog post.