我想以编程方式拍摄我的游戏的屏幕截图,就像你进入Eclipse DDMS一样.
通过此处提出的解决方案截取屏幕截图:如何以编程方式在Android中截取屏幕截图?在大多数其他SO问题中,只有View元素可见,但SurfaceView不是.
SCREENSHOTS_LOCATIONS = Environment.getExternalStorageDirectory().toString() + "/screenshots/";
// Get root view
View view = activity.getWindow().getDecorView().getRootView();
// Create the bitmap to use to draw the screenshot
final Bitmap bitmap = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmap);
// Get current theme to know which background to use
final Theme theme = activity.getTheme();
final TypedArray ta = theme
.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
final int res = ta.getResourceId(0, 0);
final Drawable background = activity.getResources().getDrawable(res);
// Draw background …Run Code Online (Sandbox Code Playgroud)