I need to let the user take a picture (from the gallery or from a camera app) with Android 6.0.
Because I don't need to control the camera, I wanted to use an intent as describe here:
However, if you don't need such control, you can just use an ACTION_IMAGE_CAPTURE intent to request an image. When you start the intent, the user is prompted to choose a camera app (if there isn't already a default camera app), and that app takes the picture. The camera app returns the picture to your app's onActivityResult() method.
https://developer.android.com/preview/features/runtime-permissions.html
But for this ACTION_IMAGE_CAPTURE, you need to fill the extra "MediaStore.EXTRA_OUTPUT" which is an Uri to a temp file (without this param I will have only a thumbnail). This temp file must be into the external storage (to be accessible by the camera app). You need the permission WRITE_EXTERNAL_STORAGE to create a file on the external storage.
So it's not possible to capture an image through native dialogs/apps without the permission android.permission.CAMERA or android.permission.WRITE_EXTERNAL_STORAGE. Is that correct?
Thanks
Security researchers at Checkmarx have discovered that a vulnerability in the pre-installed Camera app on Google and Samsung devices can accidentally give other apps on your phone access to the camera and microphone without permission.
Try this:
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(getActivity().getApplicationContext().getExternalFilesDir(android.os.Environment.DIRECTORY_PICTURES).getAbsolutePath() + File.separator + "yourPicture.jpg");
Uri uri = Uri.fromFile(file);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, url);
This gives you access to an "external" storage writable for camera apps in this case, but the files are just visible from your app. To learn a little bit more about storage spaces in android see https://www.youtube.com/watch?v=C28pvd2plBA
Hope it helps you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With