The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


ADB Tips and Tricks

Several chapters in this book offer adb recipes for doing certain things at the command line. Having the adb binary in the PATH environment variable for your development machine is very handy, so you can run such commands from anywhere.

However, those other chapters only skim the surface of what sorts of adb commands there are and what they can be used for. Several others are presented here.

Prerequisites

Understanding this chapter requires that you have read the core chapters of this book, and that you know how to work on the command line.

This is the Droid That You Are Looking For

adb works well, except when there is more than one visible Android environment, such as two devices, or a device and an emulator. Some commands — notably adb devices — work normally. Most other commands will complain that adb does not know which of the Android environments the command is supposed to act upon.

There are three switches you can include after adb and before the command that control what adb will use:

That serial number is the value given in the adb devices command. For an actual device, the serial number usually is the real serial number. For an emulator, the serial number is emulator-NNNN, where NNNN is the value before the AVD name in the title bar of the emulator window. Frequently, that value starts with 5554 and increments by two for each subsequent running emulator. Hence, -e is roughly equivalent to -s emulator-5554.

Installing and Uninstalling Apps

The preview of this section took that left turn at Albuquerque.

Playing with Permissions

The preview of this section took that left turn at Albuquerque.

Starting and Stopping Components

The preview of this section is sleeping in.

Killing Processes and Clearing Data

The preview of this section apparently resembled a Pokémon.

Changing Display Metrics

The preview of this section was traded for a bag of magic beans.