I am trying to capture screenshots for Android when I draw something on the screen and after creating the video. It seems to me that I am doing this with a for loop, but I had problems when I called the getDrawingCache () method. In principle, it works correctly, but if I change something on the screen when I call the "drawing cache", the android application closes without an error message. Below is my source code.
public void run() {
Bitmap screenshot;
File file;
FileOutputStream fileOutputStream;
this.view.setDrawingCacheEnabled(true);
for (long i = 1; record; i++) {
screenshot = (Bitmap) Bitmap.createBitmap(view.getDrawingCache());
file = new File(directory, "frm" + i + ".jpg");
try {
fileOutputStream = new FileOutputStream(file);
screenshot.compress(CompressFormat.JPEG, 10, fileOutputStream);
fileOutputStream.close();
ScreenshotRecorder.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
this.view.setDrawingCacheEnabled(false);
}
I was looking for another way to get an Android registrar, but I did not find an open source application. If anyone knows how to get Android screen capture, I am grateful. Thanks to everyone.
(I am using Xoom Tablet and Android 3.0 version)
source
share