本文介绍了捕获多张照片时出现问题:应用程序停止响应,相机预览变成绿色,并且没有照片被保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Android中的相机成功捕获了单张照片.但是,当我尝试一次捕获5张照片时,应用程序停止响应,相机预览变成绿色,并且没有照片被保存.我在堆栈跟踪中看到的内容如下(部分)

I have successfully captured the single photo using camera in Android. But when I tried to capture 5 photos at once, app stops responding, camera preview turns to green and no picture is saved. What I saw in stack trace is as follows (partial)

我正在循环调用takePicture方法来捕获多张照片;

I am calling the takePicture method in a loop to capture multiple photos;

for(int m = 0 ; m < 6; m++) {

    mPrimCamera.takePicture(null, mPictureCallbackMet, mPictureCallbackMet);
}

我正在运行Android 1.6的HTC Magic上执行此操作.我认为我使用错误的方式拍摄多张照片. 使用Android Camera API捕获多张照片的正确方法是什么?

I am doing this on HTC Magic running Android 1.6. I think, I am using the wrong way to take multiple photos. What is the correct way to capture multiple photos using Android Camera API?

推荐答案

我没有为此提供任何API支持.并且从循环中反复调用takePicture方法不起作用.因此,我得到了一种解决方法.代码仍在循环中,但我现在使用的是Thread;

I didn't find any API support for this. And repeatedly calling the takePicture method from the loop is not working. So, I get a workaround. The code is still in loop but I'm now using Thread;

private class CaptureThread extends Thread {

        @Override
        public void run() {

            int count = 0;

            while(count < mNo) {
                mFileName = mLocation + "/pic" + count + ".jpg";

                mCamera.takePicture(null, mPictureCallback, mPictureCallback);

                count++;

                try {
                    Thread.sleep(3000);
                } catch (InterruptedException exception) {
                    exception.printStackTrace();
                }
            }
        }
}

这篇关于捕获多张照片时出现问题:应用程序停止响应,相机预览变成绿色,并且没有照片被保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 09:45