Reputation: 14504
I'm doing some maintenance on an internal app that is run on a fleet of old Galaxy Tab 2 devices running Android 9. The app has some basic code that does a plain vanilla launch of the ACTION_IMAGE_CAPTURE
intent like this (I've removed some switches for different Android versions and all the try-catching):
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
photoFile = mAppUtils.createImageFile(); // Creates a file in the external public storage directory
mImageCaptureUri = FileProvider.getUriForFile(mClassContext, getApplicationContext().getPackageName() + ".provider", photoFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
startActivityForResult(cameraIntent, REQUEST_CODE_CAPTURE_IMAGE);
This code runs fine on most devices and emulators. However, on this Galaxy Tab 2 device running Android 9, the code executes fine but launches the device's default camera app (not in 'capture' mode).
So you can take photos (and fiddle with all the camera settings), but you never get the undo / tick / cross buttons after you capture a photo - instead it just shows a tiny thumbnail of the captured photo and the video feed from the camera resumes.
Any advice, or even just something to point me in the right direction, would be greatly appreciated.
Upvotes: 2
Views: 148
Reputation: 1007584
Camera apps have bugs. Pre-installed camera apps are not immune to this. Clearly, Samsung didn't bother testing your scenario. However, that's just one of many camera app compatibility issues (warning: blog post is from 2015, and so a few things are out of date, such as references to my libraries).
Use ACTION_IMAGE_CAPTURE
only if you do not actually need the photo and can live without it. On older versions of Android, such as Android 9, you could provide advice to install OpenCamera or other ones that you know work, and you could arrange to use ACTION_IMAGE_CAPTURE
with those. Android R kinda messed that up, and I don't know if my workaround there still works.
Otherwise, use CameraX or another supported camera library and take the picture directly in your app.
Upvotes: 2