Android Camera API - Force Close Does Not Release Camera Resource [closed]

佐手、 提交于 2019-12-07 14:18:36

问题


So while developing a custom camera application I've realized on rare occasions and on various devices if the app has to force close, it does not always release the camera resource.

Is there a way to find/detect the process that is holding onto this resource and kill it? Or some other technique? It is rather difficult bug to reproduce (for me anyway), but ultimately the device has to be restarted.

Thanks!


回答1:


From chasing up on all the other posts you have made on this subject, it appears like there is no sure fire way of getting the camera back after a crash without a restart of the device. A pain, to be sure. Best option is not to crash / catch everything that might fault. Which is a pretty rubbish answer, but that's what I'm endeavouring to do now.

Lots and lots of try catch !




回答2:


I suggest you to see the code of google sample apps completely. the link is as follow. https://github.com/googlesamples/android-Camera2Basic As you can see in Camera2BasicFragment, mCameraOpenCloseLock Semaphore used to resolve release resources problems.



来源:https://stackoverflow.com/questions/4799183/android-camera-api-force-close-does-not-release-camera-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!