While not critical for developers, it’s sometimes useful to be able to pull a screenshot off of an emulator or physical device. If you take a look at Figure 7.11, within the Device area in the upper-left corner of the ADM, you will see a little camera icon. With a device connected, you can click that button and grab a screen capture from the connected device. When you click the button, the ADM displays a screen similar to the one shown in Figure 7.12 (I’ve cropped the image to reduce the amount of space used for the figure). In this example, you’re seeing a portion of the screen from my Google Nexus 7 tablet.
You can use the buttons along the top of the screen to refresh, rotate, save and copy the image. Using this feature is a quick and simple way to grab a screen image for documentation or support purposes and frees you from having to perform the screen capture on the device and transfer it to your PC.
ptg11524036
FFiigguurree 77..1122 Android Emulator Screenshot
D
Deebbuuggggiinngg oonn aa PPhhyyssiiccaall DDeevviiccee
The ADM can also interact with a physical device just as it can with a device emulator. Initial testing of an application can be done on an emulator, but before any application is released, it should be tested on a representative sample of the physical devices the application is expected to run on. To use a physical device with ADM, you must connect the device to the computer system running ADM using a USB cable. Before you can do that, you must enable USB debugging on the device. The way you enable this setting varies depending on which type of Android device you are using. On some devices, enabling developer options is accomplished by simply opening the on-device Android settings application and making some selections. On other devices, it’s a little harder. You’re just going to have to figure this one out on your own, sorry.
ptg11524036
W
Waarrnniinngg
In order to be able to test on a live device, your computer system must be able to recognize an Android device when it’s connected to the system via a USB cable. If you connect a device and it’s not recognized by the system, you must resolve any connectivity issues before continuing. In my testing on Windows, I had to manually install the Google USB driver from the SDK Manager and then, in Windows Device Manager, force the installation of the right driver. You can read about the steps at www.johnwargo.com/index.php/mobile-development/nexus-7-setup- on-windows1.html.
For Samsung devices, you may need to download and install the USB drivers separately before the device is picked up correctly by Windows. See http://developer.samsung.com/android/tools- sdks/Samsung-Andorid-USB-Driver-for-Windows for additional information.
For a Google Nexus 7 tablet, for example, you have to take some special steps before you can even access the developer settings. To enable developer mode on the Nexus 7, you have to open the settings application and select About Tablet (it is the very last item on the list of options on the Settings page). On the About Tablet page, scroll down until you see the Build number item in the list. Tap on the Build number item seven times to enable the developer options on the device. As you tap, Android will pop up a little window indicating how many more times you need to tap to enable developer mode.
With that process completed, when you open the Settings application, you should be able to scroll down to the bottom of the list of options and see a Developer options option available, as shown in Figure 7.13.
FFiigguurree 77..1133 Developer Options Enabled in the Android Settings Application
Click on Developer options and you will see a screen similar to the one shown in Figure 7.14; from here you can enable USB debugging, as shown at the bottom of the figure.
ptg11524036
FFiigguurree 77..1144 Enabling USB Debugging
With USB debugging enabled, launch the ADM, then connect the Android device to the computer system using a USB cable. After the necessary device drivers initialize (see the preceding warning for information about how to deal with driver issues), ADM should connect to your device and show the connected device in its list of connected devices, as shown in Figure 7.15.
ptg11524036 In ADM, you have access to many of the same capabilities with a physical device as you do with a
device emulator, but there are differences. Refer to the Android documentation for more information about the capabilities of ADM with a physical device. ADM is a good way to pull files from or push files to a device for testing purposes. However, much of the file structure is protected, so you won’t be able to access all file locations.
W
Wrraapp--UUpp
In this chapter, I showed you how to use the free tools available from Google that help simplify Android development for Cordova. Although the Android tools do not directly assist with debugging Cordova applications, by using these tools, you can more easily determine what’s going on within your Cordova applications.
ptg11524036
8
BlackBerry 10 Development
with Cordova
Of all of the platforms that Cordova supports, the BlackBerry 10 platform most closely aligns with the Cordova approach. The hybrid application approach has been a core application type for BlackBerry for quite some time, and for BlackBerry devices, Cordova is built on top of it. In this chapter, I show you how to use the BlackBerry command-line tools to test and debug BlackBerry Cordova applications.
One of the cool things about BlackBerry development is that the BlackBerry SDK automatically integrates a web inspector like weinre into the simulator; I show you how to use it here. The Cordova team announced that it is dropping support for legacy BlackBerry devices (devices running BlackBerry Device Software 7 and earlier), so I cover only BlackBerry 10 here. To work with legacy BlackBerry devices, you need to use Cordova version 2.9 or earlier.