Service to Activity broadcast, Activity in the registration and cancellation broadcast receiver.
Activity open, then broadcasting is no problem, if Activity is not open at this time, Service Broadcasting, will not reliable? I tested like no problem, is not it should first determine whether to open and then broadcast Activity, which is more reliable and safer?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Send broadcast party do not control, the party decided to accept the received radio broadcasting under what circumstances.
If you are a registered broadcast receiver in Manifest, no matter apk has not started, you can receive the broadcast.
If you are dynamically registered in the code, it must be running under circumstances apk to receive the broadcasts.
Specific to the Activity, if you cancel the broadcast receiver onDestroy in, Activity in the background is not the case for recycling, are to receive the broadcast. If canceled onStop, as long as Activity go backstage, and will not receive the broadcast. In general, registration and cancellation of broadcasting in the corresponding function in the life cycle do. In onCreat or onStart or onResume in this book, it is appropriate cancellation in onDestroy, onStop, onPause years.
No comments:
Post a Comment