我需要拍摄屏幕截图并保存截屏。我需要这样做,而不使用任何连接到PC或没有根除手机。每当事件被触发时,我都需要这样做。例如,当广告在游戏中显示时......或者当游戏结束并显示蛇的得分等时。您可以让我知道我如何做到这一点。我看到一些tutorilas,他们给的代码,但似乎没有工作Android - 拍摄屏幕截图
private void getScreen()
{
View content = findViewById(R.id.layoutRoot);
Bitmap bitmap = content.getDrawingCache();
File file = new File("/sdcard/test.png");
try
{
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
po可以复制http://stackoverflow.com/questions/5929403/take-screenshot-of-android-screen-and-save-to-sd-card和http://stackoverflow.com/questions/5939987/android-take-通过代码截图 – DynamicMind 2011-06-15 07:18:37