Camera.open() blocking UI thread

后端 未结 1 693
鱼传尺愫
鱼传尺愫 2021-02-04 20:06

I\'ve looked at all the SO articles I could find on this but none of the solutions work for me.

When called Camera.open(), there is a 3 second (give or take) delay where

1条回答
  •  臣服心动
    2021-02-04 20:27

    Could you not continue your thread and call groups of ui commands together with the yourContext.runOnUiThread() method? Then you background any blocking code, wait for the camera to be ready, and update the ui from the background thread.

    For example:

    private class CameraHandlerThread extends ... {
        public void run() {
            getCamera();
            yourContext.runOnUiThread(new Runnable(){
                public void run()
                {
                    ...
                }
            });
        }
    }
    

    Then you can simply new CameraHandlerThread().start();

    0 讨论(0)
提交回复
热议问题