0

I created an android app with an intent service bound to an activity. I followed this excellent article.

But now I would like to send data from my IntentService to update my view (I mean, my activity).

The context: I want to create a simple countdown. The service send the "time" to the activity every minute or second for example.

How can I send data from my IntentService to my Activity ?

In kotlin please... Thank you!

psv
  • 3,147
  • 5
  • 32
  • 67
  • https://stackoverflow.com/questions/18125241/how-to-get-data-from-service-to-activity it's in java though – leonardkraemer Sep 08 '18 at 21:42
  • thank you @leonardkraemer, but there are several solutions (at least broadcastReceiver or Handler). What is the best way to do this ? And the last post talk about AIDL. Is it another way ? – psv Sep 08 '18 at 21:56
  • use the IBinder for the bound service. That will be best way to do it. Check the section: "Completing the Example" of the [this excellent article](https://www.techotopia.com/index.php/Android_Local_Bound_Services_%E2%80%93_A_Kotlin_Example) you have provided. – Ravi Rawal Sep 08 '18 at 23:43
  • @RaviRawal this is a way for the activity to access methods to the service, but I want to do the opposite: I want the service can communicate with an activity. – psv Sep 09 '18 at 07:46

0 Answers0