From the course: Intermediate Kotlin for Android Developers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Anko coroutines: Listeners
From the course: Intermediate Kotlin for Android Developers
Anko coroutines: Listeners
- [Instructor] Anko provides us with a couple of functions that we can use to make working with coroutines on android easier. Let's take a look at the most useful one. First, we need to make sure our built out gradle file has the anko coroutine dependency, just like you see here on line 39. So now we can go ahead and update our activity to take advantage of our function BG. So let's switch over there now, and here on line 27, this is where we grab our list of planets and then we populate it in our adaptor. We're just going to comment this out for now. And we're going to reference a new function, which we're going to call get planets time consuming. And this is basically just to simulate that we're executing a long running network call. So let's go ahead and use alt enter to create this function. And we'll delete the template contents. Now the first thing we want to do is to start our coroutine using the launch function. And for our coroutine context, we're going to provide the UI…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.