public void CaptureImages(View v) {
mSurfaceView.setDrawingCacheEnabled(true);
mSurfaceView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
mSurfaceView.layout(0, 0, mSurfaceView.getMeasuredWidth(), mSurfaceView.getMeasuredHeight());
mSurfaceView.buildDrawingCache(true);
Bitmap bitmap = Bitmap.createBitmap(mSurfaceView.getDrawingCache());
mSurfaceView.setDrawingCacheEnabled(false);
View v1 = findViewById(R.id.surfaceViewFrame);
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File folder = new File(Environment.getExternalStorageDirectory() + "/MediaApp");
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File fileImage = new File(Environment.getExternalStorageDirectory() + "/MediaApp"
+ File.separator + "image.jpg");
FileOutputStream fo = null;
try {
fileImage.createNewFile();
fo = new FileOutputStream(fileImage);
fo.write(bytes.toByteArray());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
showToast("Error Directory not created");
}
}
This app stream video from internet and displyes it in a surfaceview android.i place a button in the view to take a screenshot of the video.but,it always shows a blackscreen only..Any help?