Binding a local service to an action or using a broadcast receiver, which is more efficient?

What is more effective for managing class of service actions and methods? one way is to bind the local service to activity, and another way a broadcast receiver is used to send broadcast messages to control methods in the service. Are these two different ways to do the same? What do you use most of the time?

+4
source share
1 answer

Binding: if I need to change many service variables or get values โ€‹โ€‹from the service in different cases. Thus, you have access to memory for access to memory. Or, if I need to constantly get values โ€‹โ€‹from the service, and it is easier to control the exact time on the one hand. Linking should be more effective if you have a lot of posts. (The Android documentation provided an example of an example of a real-time server client)

Broadcast: if many variables change in my activity or my service, but I can always specify a point and send relatively categorized messages sent to respected recipients. Timing here may be a bit, but you can receive messages in the queue. This approach is suitable for tasks such as long-term periodic updates, etc.

+1
source

Source: https://habr.com/ru/post/1440726/


All Articles