Reputation: 9351
Which is more effective to control the actions and methods of a service class? one way is binding of a local service to an activity, and the other way is using broadcast receiver to send broadcasts to control methods in a service. They are two different ways of doing the same thing? Which do you use the majority of the time?
Upvotes: 4
Views: 887
Reputation: 5971
Binding: if I need to change many variables of the service or get values from the service in different occasions. This way you have in memory access to the variables. Or if I need to constantly get values from the service and it is easier to control the exact timing on one side. Binding should be more effective if you have a lot of communications to be done. (Android documentation gave the example of a realt time server client example)
Broadcast: if many variables gets changed in Either my activity OR my service, but I can always pin point and send send relatively categorized messages to the respected receivers. Timing here can be a little off but you can get queued messages. This one is suitable for tasks such as long term periodic updates etc.
Upvotes: 1