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.
Started services and background processing limits
From the course: Concurrent Programming with Android: Threads, Workers, and Kotlin Coroutines
Started services and background processing limits
- [Instructor] In older versions of Android, you could make a service stay alive as long as you'd like simply by calling a function named start service. A service can be both bound and started. You get access to the service's API by binding to it from the UI and you persist the service by starting it or at least that's the way it used to work. The theory of start service is that its lifecycle is independent of the activity that starts it. So if you were to close the activity, the service would stay alive. But again, that's in older versions of Android. The service stays in the same process and in the main UI thread, so if you want to run true background processing, such as making requests to the web, you still need to create your own threads or co-routines within the service itself. To start the service, you call the function start service, and you pass in the same intent object that you used to bind to it. And you…
Contents
-
-
-
-
-
-
-
(Locked)
Create and run a bound service6m 20s
-
(Locked)
Started services and background processing limits5m 24s
-
(Locked)
Play audio in a service with MediaPlayer5m 16s
-
(Locked)
Run a service in the foreground9m 45s
-
(Locked)
Send intents from a foreground notification5m 7s
-
(Locked)
Style a foreground notification2m 42s
-
(Locked)
-