I want to capture and share a view as an image. My code runs without errors. The sharing part works well, but the capture does not work. Any help is welcome.
Here the code i use.
linel1.buildDrawingCache();
Bitmap captureView = linel1.getDrawingCache();
FileOutputStream fos;
try {
fos = new FileOutputStream(Environment.getExternalStorageDirectory().toString()+"/DCIM/capture.jpeg");
captureView.compress(Bitmap.CompressFormat.JPEG, 100, fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Toast.makeText(getApplicationContext(), "Captured!", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "title");
Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory().toString()+"/DCIM/capture.jpeg"));
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/*");
startActivity(Intent.createChooser(intent, "This picture is shared"));