Logging the Activity Lifecycle

In this section, you are going to override lifecycle functions to eavesdrop on MainActivity’s lifecycle. Each implementation will simply log a message informing you that the function has been called. This will help you see how MainActivity’s state changes at runtime in relation to what the user is doing.

Making log messages

In Android, the android.util.Log class sends log messages to a shared system-level log. Log has several functions for logging messages. Here is the one that you will use most often in this book:

    public static Int d(String tag, String msg)

The d stands for debug and refers to the level of the log message. (There is more about the Log levels in the section called For ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.