I'm writing the camera application. I've started with using android.hardware.Camera
and corresponded classes. But from time to time my application failed to connect to the camera. It depends on device model and Android version. But if application works on some device fine, after a day or two it start to failing. One more thing that I noticed - if my app fails to connect then build-in camera app fails to connect too.
I read almost all post related to Camera API and related exceptions on stackoverflow and decided to replace my code with CommonsGuy's library https://github.com/commonsguy/cwac-cam2. And, unfortunately, fails are still exists.
I discovered that after fail I can use Camera API again only after device reboot.
So I want to ask is it possible to do something programmatically for making possible to use camera again without rebooting device? Maybe there is a way to kill Camera Service or upload native Camera code?
Example of fail (Nexus 4, Android 5.1):
Fatal Exception: java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.<init>(Camera.java:497)
at android.hardware.Camera.open(Camera.java:342)
at com.commonsware.cwac.cam2.ClassicCameraEngine$1.run(ClassicCameraEngine.java:78)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
So I want to ask is it possible to do something programmatically for making possible to use camera again without rebooting device?
No, sorry.