I'm trying to record android screenshots when I'm drawing something on the screen and after generate a video. I'm thought to do this with a "for" looping but I had problems when I called the getDrawingCache() method. In principle it works right, but if I change something on screen when the "drawing cache" is called, the android app is closed without error reported. 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've looked for another way to get android screen recorder, but I've not found open source apps. If someone know some way how to get android screen capture, I'm grateful. Thanks for all.
(I'm using a Xoom Tablet and android 3.0 version)