Hi,
Thanks for the quick answer.
These permissions are given (and others, not related to storage):
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
OutputFileOptions are created like this:
final ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Video.Media.TITLE, fileName.fileName);
contentValues.put(MediaStore.Video.Media.DISPLAY_NAME, fileName.fileName);
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM + File.separator + fileName.folderName);
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg");
ImageCapture.Metadata metadata = new ImageCapture.Metadata();
metadata.setReversedHorizontal(getLensFacing() == CameraSelector.LENS_FACING_FRONT);
OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(
context.getContentResolver(),
MediaStorage.getMediaUri(),
contentValues)
.setMetadata(metadata)
.build();
Then I save OutputFileResults.getSavedUri().getPath() value. (String path = outputFileResults.getSavedUri().getPath())
When I try to open the image I try this:
final Bitmap originalBitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(Uri.parse(path)));
If I simply use the code above I get the following error:
W/System.err: java.io.FileNotFoundException: No content provider: /external/images/media/100891
(of course the path is different each time)
If I try to put "file://" before the path when creating the uri I get FileNotFoundException and says "open failed: ENOENT (No such file or directory)".
How should I use the path value? Is there any java example? I found only examples to recreate the whole stuff (using the real file name and creating contentValues and so on) but then what is the path we get in OutputFileResults?
Thanks in advance,
Peter