Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am facing this issue, it occurs rarely but once it occurs user cannot go forward as there is no workaround that I am able to do.
While the user clicks on capture the camera is working in the background, but still i am getting camera is closed error.
Device info :
Brand : Nokia
Android version : 10
Model : Nokia 6.1 Plus
This is the code I am using to capture image
imageCapture.takePicture(outputFileOptions, ContextCompat.getMainExecutor(getContext()),
new ImageCapture.OnImageSavedCallback() {
@Override
public void onImageSaved(ImageCapture.OutputFileResults outputFileResults) {
imagePath = FileProvider
.getUriForFile(getContext(), getContext().getPackageName() + ".provider", imageFile);
checkImageOrientation();
@Override
public void onError(ImageCaptureException error) {
// Error is : **Camera is closed.**
–
–
In CameraX the ImageCapture use case is stable so this bug shouldn't occur even rarely, so in the cases of the error, the camera is closed due to either a problem in your logic of when exactly you are calling imageCapture.takePicture()
, or for example when you take a picture and the app pauses before the image is saved, it will throw the error you mentioned.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.