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
From the course: Concurrent Programming with Android: Threads, Workers, and Kotlin Coroutines
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
-
-
-
-
-
-
(Locked)
Run background tasks with IntentService5m 22s
-
(Locked)
Upgrade IntentService to JobIntentService4m 37s
-
(Locked)
Send results from JobIntentService to the UI7m 25s
-
(Locked)
Manage deferrable tasks with WorkManager5m 35s
-
(Locked)
Set work request constraints3m 9s
-
(Locked)
Get results from a background worker4m 56s
-
(Locked)
Send progress updates from a background worker5m 2s
-
(Locked)
-
-