Skip to content

Instantly share code, notes, and snippets.

@nikreiman
Created July 7, 2011 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikreiman/1069416 to your computer and use it in GitHub Desktop.
Save nikreiman/1069416 to your computer and use it in GitHub Desktop.
Take a screenshot of a currently connected Android device to the desktop
#!/bin/bash
# This is a simple script which will take a screenshot from a currently
# connected Android device and dump it to the user's desktop.
# Written by Nik Reiman: nikreiman@shortmail.com
# INSTALLATION:
# For this tool, you will need the Android SDK installed, and you will also
# need to build the Android "screenshot" tool.
#
# To build the screeshot tool, you must download the source by running:
#
# git clone git://android.git.kernel.org/platform/sdk.git
#
# Once you have the base platform cloned, cd into the "sdk" directory
# and run the following:
#
# mv ddms/libs/ddmlib/src/com/android/ddmlib screenshot/src/com/android/
#
# Now move the "screenshot" directory to any location of your choosing.
# You can now remove the rest of the "sdk" sources. Next, cd to the
# screenshot source root (ie, "screenshot/src") and run:
#
# javac com/android/screenshot/Screenshot.java
#
# Set these lines to match where you installed the Android SDK and the
# screenshot tool (as described above)
androidSdkPath=$HOME/Code/SDK/android-sdk-mac_86
screenshotToolPath=$HOME/Code/GitHub/android-screenshot/src
screenshotOutputPath=$HOME/Desktop
# That's it! Happy screenshooting!
PATH=$PATH:$androidSdkPath/platform-tools
currentDate=`date "+%d %b %Y %H.%M.%S"`
printf -v outputFile "Android Screenshot %s.png" "$currentDate"
cd $screenshotToolPath
java com/android/screenshot/Screenshot -d "$screenshotOutputPath/$outputFile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment