Open LainCoubrt opened 6 years ago
The steps to reproduce:
We need an app that doesn't release the camera when it goes to background. So I downloaded google sample project of camera2Basic. And onPause() of the Camera2BasicFragment, commented closeCamera() and stopBackgroundThread().
Now just open QREader demo app then this app created. Now just click overview button that displays apps in "cascade" and click the demo app and it will crash with the RuntimeException.
@LainCoubrt I will look into it. The develop
branch has some updates which are yet to be released. It also has a onError listener. If it works for you, I would suggest you check out the module and use it for the time being. Be aware it has not been tested which is why it has not been released. I need to test and put in a lot of fixes before releasing it.
However if it doesn't fix it, I will need to look into the issue and provide you a fix whenever I can make it available. Thank you for providing the steps to reproduce the issue.
Hi. I had the RuntimeException: Fail to connect to camera service. Log:
This is due to the camera being used from another app and not be released when the app goes to background.
I can give the steps to reproduce this issue if you need.
This exception is thrown in QREader.java in line 221, and is not caught by the IOException beacause it's a RunTimeException and we can't catch it because it's thrown in a background thread when surface is created.
So to just fix the crash just change the IOException for just an Exception.
Although this resolves the issue i think it's important to send feedback to the user and just catch the exception and print the error we cant do that. I think it would be useful some sort of listener so we could know the errors when the camera fails.
Please if you could change this as soon as possible would be very helpful. And if you need any help just ask.