From the course: Android Development Essential Training: 3 Navigation
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Trace lifecycle events - Android Tutorial
From the course: Android Development Essential Training: 3 Navigation
Trace lifecycle events
- [Instructor] Android activities change state through a series of lifecycle events. You can hook into these events by overriding the methods in your Activity class. In the sample project from the course repo, we've already implemented one of those callback methods, onCreate. You can see that here on line number 11. Let's add a log statement to the end of the function so that we can monitor when and what actions trigger this callback. I'll come here to the end of the function starting on line number 14, and I'll add a few empty lines. Next, I'll start typing in Log, and then this is going to pop up the android.util.Log class. And we're going to add an info log. First, let's make sure we import it. So we'll use our quick actions, Alt + Enter, and then we'll import the log. Next, we need to add a tag. We're going to call it LOG_TAG, and we'll create this constant in one second. And then, we're going to print out onCreate.…
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.