Debug and Test Settings

With the Dev Tools application, you can turn on a number of settings that will make it easier to test and debug your applications. To get to the development settings page on the emulator, launch theDev Tools application and open Development Settings. This will open the development settings page with the following options (among others):

• Debug app Selects the application that will be debugged. You do not need to set this to attach a debugger, but setting this value has two effects:

o It will prevent Android from throwing an error if you pause on a breakpoint for a long time while debugging.

o It will enable you to select the Wait for Debugger option to pause application startup until your debugger attaches (described next).

• Wait for debugger Blocks the selected application from loading until a debugger attaches. This way you can set a breakpoint in onCreate(), which is important to debug the startup process of an Activity. When you change this option, any currently running instances of the selected application will be killed. In order to check this box, you must have selected a debug application as described in the previous option. You can do the same thing by adding waitForDebugger() to your code.

• Immediately destroy activities Tells the system to destroy an activity as soon as it is stopped (as if Android had to reclaim memory). This is very useful for testing theonSaveInstanceState(Bundle) / onCreate(android.os.Bundle) code path, which would otherwise be difficult to force. Choosing this option will probably reveal a number of problems in your application due to not saving state.

• Show screen updates Flashes a momentary pink rectangle on any screen sections that are being redrawn. This is very useful for discovering unnecessary screen drawing.

• Show CPU usage Displays CPU meters at the top of the screen, showing how much the CPU is being used. The top red bar shows overall CPU usage, and the green bar underneath it shows the CPU time spent in compositing the screen. Note: You cannot turn this feature off once it is on, without restarting the emulator.

• Show background Displays a background pattern when no activity screens are visible. This typically does not happen, but can happen during debugging.

These settings will be remembered across emulator restarts.

0 0

Post a comment