Answer the question
In order to leave comments, you need to log in
What are the ways to exchange activity-service data?
Hello.
Not so long ago I write for android.
Correctly, I understand that the data exchange between the activity and the service is carried out: -
from the activity to the service binding - to
the activity from the service broadcast receiver
I used these methods, everything is fine, everything works. But am I missing something? Are there any other ways?
Answer the question
In order to leave comments, you need to log in
1) If the service is in the same process, then you can communicate at the instance level. When binding, the activity receives a link to the service instance and then the usual Java.
2) If the service is in another process, then:
2.1) messengers - when binding, the service and activities exchange messengers and communicate.
2.2) AIDL is a tricky wrapper for transactions through binders, in fact it is also a binder, but, unlike messengers, it is close to a simple method call.
All methods above work both ways.
If the binding does not suit you, then broadcast.
Moreover, if communicating in the same process, then it is better to use LocalBroadcastManager to avoid all sorts of security holes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question