From the course: Concurrent Programming with Android: Threads, Workers, and Kotlin Coroutines

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Send results from JobIntentService to the UI

Send results from JobIntentService to the UI

- [Instructor] When you run code in an intent service or a job-intent service, you don't have a direct connection back to the user interface, but you can package data in something called a result receiver, and send that back to the UI. You can send anything that fits in a bundle; strings, numeric values and data objects that implement the parcelable interface. For this demonstration, I've simplified my intent service and also made it do something useful. I have a new key called file URL. I still have my job ID that I used previously and in my on-handle work function, I'm receiving a URL, a string, turning that into a real URL object and then reading the text. So I could use this to read something in storage or over the web. And right now I'm just using log cad output to output the contents. In the main activity, when I call the services start action function, I'm using this file URL that I've now placed in the…

Contents