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!
In Android there are many APIs which allow us to send messages from a service to an activity. Which API we should use that depends on whether the service and the activity are running in the same process or not.
If they are running in the same process, then you have 2 options
If they are running in different processes, then you have 3 options
Handler
sequentially. Messenger
and AIDL
is AIDL
can execute tasks on binder threads concurrently.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.