0

This maybe look trivial, but I can't find a way to send data from my service to the activity. All samples I found use LocalBroadcastManager that is now deprecated. Can someone post a concrete example of how to do?

zeus
  • 12,173
  • 9
  • 63
  • 184
  • You can use LiveData, here is a good example https://stackoverflow.com/questions/68995642/how-can-i-update-ui-from-service-using-livedata – Abhishek Kumar Oct 31 '22 at 18:02
  • There's a variety of ways depending on if its pull vs push, the type of data, if the service is in the same process or another, if its a bound service or not, the frequency of the data changes, etc. Describe what you're actually trying to do. – Gabe Sechan Oct 31 '22 at 18:17
  • @GabeSechan The service is listening Firebase message (fcm) and pass it to the main activity if it's alive, else store it locally so that app can retrieve it when it's get started – zeus Oct 31 '22 at 20:16
  • @zeus Services don't listen to FCM messages. BroadcastReceivers do. – Gabe Sechan Oct 31 '22 at 21:13
  • @GabeSechan yes but i did a service to do this ... – zeus Oct 31 '22 at 21:22

0 Answers0