android:onAutoFocus()不会触发android 4.0(Ice cream sandwich)虚拟设备

我每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;
        }
    }

最佳答案 你的代码似乎是正确的.问题是,在你的AVD上,你的摄像头就是你的网络摄像头或类似的东西.这个网络摄像头有一个静态焦点,所以你的代码不能用它…

如果你想测试一下,试着将你的手机升级到4.0,如果你需要帮助,你可以看一下galaxy s看看这里:http://forum.xda-developers.com/forumdisplay.php?f=656

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

最好的祝福

苹果浏览器

点赞