app hanging on camera.release()

一世执手 提交于 2019-12-05 20:27:39
coder_For_Life22

Try putting it in a thread to run in the background so it wont hang up the UI.

new Thread(new Runnable(){
    public void run(){
        camera.setPreviewCallback(null); // PreviewCallback de_init.
        camera.stopPreview(); // stop Preview
        camera.release();
    }
}).start();
Leandro

For me, the solution that works is:

Try{
    camera.stopPreview();
    camera.setPreviewCallback(null);   
    camera.release();
    camera = null;
} catch (Exception e){
    //...
}

I`ve solved this isuue adding camera.unlock() before release()

camera.stopPreview();
camera.setPreviewCallback(null);
camera.unlock();
camera.release();
camera = null;

test on more devices needed...

just call your methods like

mCamera.stopPreview();
mCamera.setPreviewCallback(null);
mCamera.release();

you have to call setPreviewCallback(null) betweeen stopPreview and camera.releass

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