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.

Run background tasks with IntentService

Run background tasks with IntentService

- [Instructor] So far in this course, I've described the use of threads and Coroutines to run code concurrently. Those work really well for shorter tasks, tasks that you can run in the context of an activity, a fragment, or a view model. But when you need to run longer operations say, downloading large amounts of content over the web, you'll want to put that sort of code in separate architectures and there are a number of different options available. I'm going to start with a class named and IntentService. This is a special kind of service that's launched by calling a start service function and passing an intent object. The magic of an IntentService is that it runs in its own background thread, so you don't need to do anything special to create a background thread. It's already happening. I'm going to start showing off the classic or legacy IntentService class. It's important to know from the beginning though, that…

Contents