I am currently developing an android service app. A problem arose while developing a foreground service app. This is the situation when the activity gets data from the service. One way is to use a bind service and call a method from the service instance.
Another way is to get data using intents.
I've searched a lot, but almost all of them are using intents. If the lifecycle fits well, isn't it convenient and good to call a function as a bind service? I'd like to hear your opinion.
(In the service, it does not actually work, but creates and manages a working thread.)
f
FunkyMuse
12/28/2021, 3:31 PM
You can use shared flow, state flow, channels...
👍 1
u
이준학
12/29/2021, 1:06 AM
@FunkyMuse Yeah, i use shared flow now. Service has State flow. And thread emits new data to state flow, Activity only subscribe the state flow in service. So I think that there is no atomic issue to synchronize between main thread and worker thread.