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