Android developers need to be able to grab a screenshot of their App running on a device or the emulator. This is because when the App is published on Google Play (previously known as Android Market) one of the requirements is at least two screenshots. The ability to take a screenshot helps with the production of a website to support the App (online user guides, manuals, training and quick start guides). There is also the production of marketing materials and good old fashioned printed user guides or manuals.
It is most likely that the screen capture will be done during the final testing phases of the App on a developers computer. The App will be running on a Android Virtual Device (AVD) configuration or on a device physically tethered to the computer, usually connected via a USB cable. This tutorial explains how easy it is to capture the screen for an Android device from within the Eclipse programming environment. If you have a App project handy start up Eclipse now and give it ago. Alternatively install Eclipse (see this article) and try it with one of our example projects.
Execute the project so that it is running on an AVD or physical device. In the upper right hand corner of Eclipse click the Open Perspective button, or use the Eclipse Window menu and select Open Perspective. This will open a menu with several options.
From the Open Perspective menu chose the Dalvik Debug Monitor Server (DDMS) entry. The DDMS is provided with the Software Development Kit (SDK) and is available from Eclipse when the Android Development Tools (ADT) plugin is installed.
If the DDMS Perspective has been opened previously then a button in the upper right corner of Eclipse may be visible that can be clicked to bring the perspective up. If the perspective buttons cannot be seen in the top right their docking may have been moved to the left hand side, or the toolbar may be hidden. Use the Window menu to open the DDMS via Open Perspective (the Window menu can also be used to redisplay the toolbar).
Locate the Device dialog in the perpective. If the device list cannot be seen use the Window menu option to Reset Perspective. In this dialog will be a list all the running AVDs and all the connected physical devices. Select the device or AVD from which the screenshot is required. Then click on the Screen Capture icon on the Device dialog toolbar. The Device Screen Capture dialog will appear and a few moments later the screenshot for the selected device. There are five buttons on the dialog:
- Refresh – Update the screenshot, usually used to grab a new screenshot after performing an action on the App.
- Rotate – Flip the screen capture through ninety degrees, used when capturing devices or AVDs in landscape orientation.
- Save – Write the screenshot to disk.
- Copy – Copy the screen captured to the computer’s clipboard (for later pasting into a document or image manipulation program such as GIMP or Paint.net).
- Done – Close the screen capture dialog.
Click Done when finished capturing screenshots to return to Eclipse, use the Java perspective button or menu option to return to the normal Java editing screens.
Note: Depending upon the size of the screen from which the image was captured the image may need resizing if used for the Google Play screenshots. Screenshots are specified as either 320×480 (HVGA portrait) or 480×800 (WVGA800 landscape) for Google Play requirements. To prevent the need to resize screen dumps capture them from a HVGA device or emulator (good for phone Apps) or a WVGA800 device or emulator (good for tablet Apps).