O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4Debugging Android Apps

In this chapter, you will find out what to do when apps get buggy. You will learn how to use LogCat, Android Lint, and the debugger that comes with Eclipse.

To practice debugging, the first step is to break something. In QuizActivity.java, comment out the code in onCreate(Bundle) where you pull out mQuestionTextView.

Listing 4.1  Comment out a crucial line (QuizActivity.java)

@​O​v​e​r​r​i​d​e​ p​r​o​t​e​c​t​e​d​ ​v​o​i​d​ ​o​n​C​r​e​a​t​e​(​B​u​n​d​l​e​ ​s​a​v​e​d​I​n​s​t​a​n​c​e​S​t​a​t​e​)​ ​{​ ​ ​ ​ ​s​u​p​e​r​.​o​n​C​r​e​a​t​e​(​s​a​v​e​d​I​n​s​t​a​n​c​e​S​t​a​t​e​)​;​ ​ ​ ​ ​L​o​g​.​d​(​T​A​G​,​ ​"​o​n​C​r​e​a​t​e​(​)​ ​c​a​l​l​e​d​"​)​;​ ​ ​ ​ ​s​e​t​C​o​n​t​e​n​t​V​i​e​w​(​R​.​l​a​y​o​u​t​.​a​c​t​i​v​i​t​y​_​q​u​i​z​)​;​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required