捕获图像后调用 StartPreview() 的最佳方法是什么?
一旦调用 Camera.takePicture(),我的预览将停止更新,如文档中所述。检测图像捕获过程已完成并调用 startPreview() 使其再次开始更新的最佳方法是什么?
根据文档,该调用不能放置在传递给 takePicture 的任何回调中,因为它们应该在我调用它之前全部返回。
我当前最好的猜测是创建一个 Handler 并从 JPEG 回调(或最后定义的回调返回的那个)向其发送延迟的 Runnable。
Once a call is made to Camera.takePicture(), my preview will stop updating as described in the docs. What's the best way to detect that the image capture process is finished and call startPreview() to make it start updating again?
The call can't be placed in any of the callbacks passed to takePicture, according to the docs, as they should all have returned before I invoke it.
My current best guess is to create a Handler and post a delayed Runnable to it from the JPEG callback (or whichever is the most last defined callback to return).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于 PictureCallback 无论如何都是在单独的线程中启动的(它不会锁定 UI),因此您不需要使用 AsyncTask 来调用捕获。
有两种方法可以完成您想做的事情,最简单的方法如下:
第二种方法是使用匿名函数,例如:
两者都有其用途,具体取决于您的需要。
Since the PictureCallback is started in a separate thread anyway (it will not lock the UI), you don't need to use an AsyncTask to call the capture.
There are two ways to do what you want to do, the easiest is the following:
The second would be using an anonymous function, e.g.:
Both have their uses, depending on your needs.
您应该从 AsyncTask(或线程)中启动 mCamera.takePicture,但 AsyncTaks 是更简单的选择。
一个非常简单的实现(当然可以修改)是:
拍照时调用的方法
AsyncTask 子类
PictureCallback 字段
You should start the mCamera.takePicture from within an AsyncTask (or a thread) however AsyncTaks's are the easier option.
A really simple implementation (which of course can be modified) is to:
The method called to take the picture
The AsyncTask subclass
The PictureCallback field