私のアプリケーションでは、サーフェスビューで画面をキャプチャしたいのですが、背景で描画された画面をキャプチャできません。背景とともに描画された画面を保存する方法.この問題を解決する方法を教えてください.
View content = findViewById(R.id.relative21);
content.setDrawingCacheEnabled(true);
SurfaceHolder sfhTrack = drawingSurface.getHolder();
sfhTrack.setFormat(PixelFormat.TRANSPARENT);
private void getScreen() {
// TODO Auto-generated method stub
View content = findViewById(R.id.relative21);
Bitmap bitmap = content.getDrawingCache();
File myDir=new File("/sdcard/saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".png";
File file = new File (myDir, fname);
try
{
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
上記のコードを試してみましたが、背景を保存できますが、描画されたものを保存できません。