Проверьте этот код, чтобы сохранить экран как изображение.
private void saveImages() {
View v = findViewById(R.id.view_images);
v.setDrawingCacheEnabled(true);
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will
// be null
v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
v.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
v.setDrawingCacheEnabled(false); // clear drawing cache
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyyMMddHHmmss");
Date date = new Date();
String name ="data"+"-"+dateFormat.format(date) + ".png";
// String imageName = "TEST" + (String) name;
File folder = new File(Environment.getExternalStorageDirectory()
+ "/.TEST");
// boolean success = false;
if (!folder.exists()) {
folder.mkdir();
}
File file = new File(folder + "/TEST" + name);
try {
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
b.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
Log.d("Done", "Yes");
Toast.makeText(getApplicationContext(),
"Images" + name + "save in Sd card", Toast.LENGTH_SHORT)
.show();
} catch (Exception e) {
e.printStackTrace();
Log.d("Done", "No");
Toast.makeText(getApplicationContext(),
"Images in Sd card", Toast.LENGTH_SHORT).show();
}
finish();
}