Android Background Processing

Sep 23 2022 · Kotlin 1.6, Android 12, Android Studio Chipmunk 2021.2.1

Part 3: Use Android Services

15. Introduction

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 14. Conclusion Next episode: 16. Use Android Service

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 15. Introduction

The student materials have been reviewed and are updated as of SEPTEMBER 2022.

Transcript: 15. Introduction

Great job! You’ve reached the third part of the course, where you’ll learn more about another background processing mechanism called Services! :]

WorkManager is really useful when you need to run a piece of work in the background. Or if you need to chain a lot of work, and their results. But sometimes you need to run work for a long period of time, or you need to run some work, without really caring about its result.

This is where services come in handy! Services are one of the core Android components, built specifically for running work in parallel with the rest of the app. They often represent long running operations, like synchronizing data or playing music.

Services can come in many types. The most basic distinction between services is them being foreground, background and bound to a specific Android component.

Each service type works differently in terms of visibility, their lifecycle, and the threading behind the scenes.

The most common service type is the background service. It’s a service which runs some code away from the main thread, and usually doesn’t show its behavior or progress to the user.

Background in this specific case means away from the eyes of the user! They are used for things like synchronizing the database. Things which the user doesn’t really care about!

When you have a piece of work which may or may not run in a background thread, but you need to display its progress to users, you use a foreground service.

In fact, as of API 26, or Android Oreo, background services have been restricted by the system, and you can only run a handful of services in the BG, while the app is inactive. Foreground services must display a notification, so the user knows they are running, and possibly draining the battery or using up data.

Most services are not bound to any specific Android component. They are called unbound services. But sometimes, you want to bind a service to another Android component, and achieve interprocess communication.

Interprocess communication, or IPC, is very useful in distributed computing, but most applications don’t fit in that use case. However, you can bind a service to a component, and use it for IPC. These services are called bound services.

For the purpose of this course, you won’t cover bound services, as they are too specific for an everyday course. There are also different types of services, when it comes to the class they extend.

For the most part, you use the basic Service. It has everything you might need in a general use case. Sometimes, however, you want to bind a service to a specific job, or piece of work. These services can be IntentServices, or JobIntentServices. You’ll implement all three mentioned types, in this course.

You should be ready to dive into the practical examples now! See you in the next episode, where you’ll implement a basic Android Service! :]