Your next career begins with
Save 50% off your seat in our next iOS Bootcamp. Limited time only. Sessions start April 3.
Lifecycle-Aware Components in Android
Nov 1 2022 Kotlin 1.6, Android 12, Android Studio Chipmunk 2021.2.1
Part 1: Lifecycle-Aware Components in Android
1. Use Spoonacular API

Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
About this episode
Get a quick overview of the AwarenessFood app with setting up the API key from the Spoonacular API.
Instructors
Contributors
Over 300 content creators. Join our team.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Watch this episode for free — or access the full course as a Kodeco Subscriber. Learn more about the benefits of subscribing here
This video Use Spoonacular API was last updated on Nov 1 2022
Hi and welcome to the course. In this course, we are going to understand what exactly is a lifecycle-aware component. But to understand this with clarity, we will also explore what are lifecycles in Android, what are lifecycle observers, understand what are Event and States, who are called lifecycle owners?, importance and usage of LiveData, and last but not least how to write test case for lifecycle-aware components.
And we are going to understand all these topics using a demo application named AwarenessFood application. So before we start with the concepts, let’s take quick look at our demo application.
Open your Android Studio and import the starter project. Which you can get from the downloadable material of this episode.
While your project is getting built, go to spoonacular.com/food-api
. It’s basically a RESTful webservice for the food API which we will use in our project. So from here, I want you to create your account, it’s totally free. Signup and then login.
Within your API Console, go to profile, click this “Show / Hide API Key” and copy this API key.
Go back to your Android Studio, navigate to the di
package and open RecipesModule file. Here, replace this text with your API key. Like this!
Close the file and run your application.
You should be able to get a recipe on your screen - like this. So this screen is basically our MainActivity
.
If you click this refresh icon, then it will load another recipe from the API.
Next, from your menu if you go to ‘Food Trivia’ then this will open up FoodTriviaActivity
with FoodTriviaFragment
inside it.
Well, this fragment contains a button at the center, which at present does nothing. We will add functionality to this button as we proceed with the course.
Now, if you take a look at the project, it contain a few packages and classes which you should get acquainted with.
-
analytics
package contains classes for tracking application events. -
data
package contains model classes. -
di
package contains classes for providing dependency injection using HILT. -
monitor
contains classes for observing network connectivity. -
network
contains classes for accessing the external APIs using Retrofit. -
repositories
package contains classes for managing persistence. -
viewmodels
containsViewModel
classes which contains the business logic.
And then we have a small views
package which contains a custom View
.
And of course, down below within the main package we have our Activity
and Fragment
, even the Application
class in place.
So basically we are using a clean application architecture as recommended by Google. So yes, that’s all for this episode.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.
Learn more