How can we communicate/pass data betweeen service and fragment
I am trying to make a service and i am doing some action in that and i want to update my fragment ui state according to that action which is performed through service but i don't know how to do it
There are many ways you can do that
First and easy way is you can directly get service variable in fragment like this :
Next you can use stateflow or livedata in service and collect/observe it in fragment like this :
Service file :
Fragment file :