4

我每 3 秒自动聚焦一次,我的代码在我的硬件设备(Galaxy S)上运行,但在我的 AVD(虚拟设备)上,应该在聚焦完成后调用的回调永远不会被调用。有人知道为什么吗?

public void onPreviewStart(){
        Log.v(TAG,"onPreviewStart() focusTimer: "+focusTimer);
        if(this.autoFocus == true && getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS)){
            focusTimer = new Runnable() {
                public void run() {
                    Log.d(TAG, "focus run..");
                    if(preview != null && preview.camera != null && !saving){
                        focusing = true;

                        Log.d(TAG, "focusing.."+preview);
                        //  ----> this gets called each 3 seconds
                        preview.camera.autoFocus(new Camera.AutoFocusCallback() {   

                            public void onAutoFocus(boolean success, Camera camera) {
                                // ----> this never gets called on ICS :(
                                Log.d(TAG, "onAutoFocus()");
                                focusing = false;
                                if(shootButtonWasPressed){  // if shooting was scheduled
                                    Log.d(TAG, "shootButtonWasPressed");
                                    shoot();
                                    shootButtonWasPressed = false;
                                }
                            }
                        });
                    }
                    preview.postDelayed(focusTimer, 3000);
                }
            };
            Log.v(TAG,"focusTimer run()");
            focusTimer.run();
        }else{
            focusTimer = null;
        }
    }
4

1 回答 1

2

你的代码似乎是正确的。问题是,在您的 AVD 上,您的相机是您的网络摄像头或类似的东西。这个网络摄像头有一个静态焦点,所以你的代码无法处理它......

如果您想对此进行测试,请尝试将您的手机升级到 4.0,如果您需要帮助,请看这里:http: //forum.xda-developers.com/forumdisplay.php?f=656

我希望你现在能看到问题!

最好的祝福

苹果浏览器

于 2012-05-28T08:30:33.387 回答