
Logcat is nothing but a solution to this type of problem. If our application crashes then it is very difficult to find out the errors that occured when our application was running. Such applications have lots of modules and contain n number lines of code. Suppose, we are developing a large application such as a Soical Media application, E-Commerce application, News application etc. Logcat helps developers to debug the code when an application is not running or has crashed. In QuizActivity.java, add a TAG constant to QuizActivity: Listing 3.1 Adding TAG constant ( QuizActivity.Logcat is an important tool in Android studio. This makes it easy to determine the source of a particular message. The first string is typically a TAG constant with the class name as its value. (There is more about the Log levels in the final section of this chapter.) The first parameter identifies the source of the message, and the second is the contents of the message. The d stands for “debug” and refers to the level of the log message. Here is the one that you will use most often in this book: public static int d(String tag, String msg)

Log has several methods for logging messages. In Android, the class sends log messages to a shared system-level log. Each implementation will simply log a message informing you that the method has been called. In this section, you are going to override lifecycle methods to eavesdrop on QuizActivity’s lifecycle. You override them in your activity subclasses, and Android calls them at the appropriate time. It is important to understand that you never call onCreate(.) or any of the other Activity lifecycle methods yourself. Setting listeners on widgets to handle user interaction Inflating widgets and putting them on screen (in the call to ( setContentView(int))

Typically, an activity overrides onCreate(.) to prepare the specifics of its user interface: The OS calls this method after the activity instance is created but before it is put on screen. You are already acquainted with one of these methods – onCreate(Bundle).

Subclasses of Activity can take advantage of the methods named in Figure 3.1 to get work done at critical transitions in the activity’s lifecycle.
