@Reck says that there is a mistake in the implementation of Genymotion, so we can not take screenshots on 2.3.7. This means that Android Studio / DDMS cannot get the correct pixels. adb shell screencap says that there is no screencap command.
Assuming you have access to the code, you can simply call this method:
public static void screenshot(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); view.draw(new Canvas(bitmap)); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); try { File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); storageDir.mkdirs(); File file = File.createTempFile(timeStamp, ".png", storageDir); bitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(file)); Log.i("SCREENSHOT", "adb pull " + file); } catch (IOException e) { Log.e("SCREENSHOT", "Cannot save screenshot of " + view, e); } }
In action:
screenshot(getWindow().getDecorView());
In the fragment:
screenshot(getActivity().getWindow().getDecorView());
The only limitation that I know is that it will not include a status bar.
TWiStErRob Sep 26 '14 at 13:19 2014-09-26 13:19
source share