Launching Android Applications on a Handset

It's time to load your application onto a real handset. To do this, you need to plug a handset into your computer, using the USB data cable.

To ensure that you debug using the correct settings, follow these steps:

1. In Eclipse, choose Run, Debug Configurations.

2. Double-click DroidDebug Debug Configuration.

3. On the Target tab, set Deployment Target Selection Mode to Manual. You can always change it back to Automatic later, but choosing Manual will force you to choose whether to debug within the emulator (and choose an AVD) or a device, if one is plugged in, whenever you choose to debug.

4. Apply your changes by clicking the Apply button.

5. Plug an Android device into your development computer, using a USB cable.

6. Click the Debug button within Eclipse.

A dialog (Figure 1.9) appears, showing all available configurations for running and debugging your application. All physical devices are listed, as are existing emulators that are running. You can also launch new emulator instances by using other AVDs you have created.

7. Double-click one of the running Android devices. There should be one listed for each handset plugged into the machine, in addition to one for each emulator instance running. If you do not see the handset listed, check your cables and make sure you installed the appropriate drivers, as explained in Appendix A.

Eclipse now installs the Android application on the handset, attaches a debugger, and runs the application. Your handset now shows a screen very similar to the one you saw in the emulator. If you look at the DDMS perspective in Eclipse, you see that logging information is available, and many features of the DDMS perspective work with real handsets as well as the emulator.

New to Eclipse?

If you're still learning the ropes of the Eclipse development environment, now is a great time to check out Appendix B, "Eclipse IDE Tips and Tricks."

0 0

Post a comment