Skip to content

Instantly share code, notes, and snippets.

@marijnvdwerf
Created October 11, 2013 10:39
Show Gist options
  • Save marijnvdwerf/6932758 to your computer and use it in GitHub Desktop.
Save marijnvdwerf/6932758 to your computer and use it in GitHub Desktop.
ScreenshotActivity
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
View rootView = findViewById(R.id.root);
rootView.setDrawingCacheEnabled(true);
Bitmap b = rootView.getDrawingCache();
try {
b.compress(Bitmap.CompressFormat.PNG, 95, new FileOutputStream("/sdcard/screen.png"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment