Android Tutorial

(avery) #1

By : Ketan Bhimani


68 

Specifically, there’s a red AndroidRuntime error: java.lang.Error:
Whoops Back in the emulator, click the Force Close button. Now set
a breakpoint on the forceError() method by right-clicking on the left
side of the line of code and choosing Toggle Breakpoint (or
Ctrl+Shift+B).

In the emulator, restart your application and step through your
code. You see My First Android App has thrown the exception and
then the exception shows up in the Variable Browser pane of the
Debug Perspective. Expanding the variables contents shows that it
is the “Whoops” error.

This is a great time to crash your application repeatedly and get
used to the controls. While you’re at it, switch over to the DDMS
perspective. You note the emulator has a list of processes running
on the phone, such as system_process and com.android.phone. If
you launch MyFirstAndroidApp, you see com. androidbook .myfirs
tandroid app show up as a process on the emulator listing. Force
the app to close because it crashes, and you note that it disappears
from the process list. You can use DDMS to kill processes, inspect
threads and the heap, and access the phone file system.

Adding Logging Support to Your Android Application

Before you start diving into the various features of the Android
SDK, you should familiarize yourself with logging, a valuable
resource for debugging and learning Android. Android logging
features are in the Log class of the android.util package.
Free download pdf