I am trying to open a camera to take picture by using the code its work proper up to android 6.0 . But in android version 7.0 it is giving error
Error
file:///storage/emulated/0/04082017_1136image.jpg exposed beyond app through ClipData.Item.getUri()
private void takePhotoFromCamera()
{
AnimateImageButton();
boolean result = Utility.checkPermission(MainActivity.this);
if (result) {
try {
_isOpenGallery = false;
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm").format(new Date());
File file = new File(Environment.getExternalStorageDirectory() + File.separator + timeStamp + "image.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intent, REQUEST_CAMERA);
System.out.println("Hello >>>>>>>> : " + file.getAbsolutePath());
}catch (Exception e)
{
Log.d("logforcamera",e.getMessage());
}
}
}
activity result code
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
File file = new File(Environment.getExternalStorageDirectory() + File.separator + timeStamp + "image.jpg");
System.out.println("Helllloooo >>>>>>>>>>> : " + file.getAbsolutePath());
Bitmap bitmap = decodeSampledBitmapFromFile(file.getAbsolutePath(), widthX, heightY);
System.out.println("Bitmap : " + bitmap);
if (bitmap != null)
{
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
showSelectedImage(bitmap);
}