Android Background Processing

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

Part 1: Run Background Work

02. Launch Threads & Post to the Main Thread

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: 01. Introduction Next episode: 03. Implement a Simple Worker

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: 02. Launch Threads & Post to the Main Thread

The student materials have been reviewed and are updated as of SEPTEMBER 2022. The image desplayed for the first project(and therefore its url) has changed. Don’t worry, the code stays the same :]

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

This course has a few sample projects you’ll use to learn about background processing in Android.

val imageUrl = URL("https://cdn.pixabay.com/photo/2018/01/14/23/12/nature-3082832__480.jpg")
val connection = imageUrl.openConnection() as HttpURLConnection
connection.doInput = true
connection.connect()

val inputStream = connection.inputStream
val bitmap = BitmapFactory.decodeStream(inputStream)

image.setImageBitmap(bitmap)
Thread(Runnable {

}).start()
runOnUiThread { ... }