I am automatically focusing each 3 seconds, and my code works on my hardware device (Galaxy S), but on my AVD (virtual device) the callback, which should be called after the focus has finished, never gets called.
Someone knows why?
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;
}
}
You’re code seems to be right. The problem is, on your AVD, you’re camera is your webcam or something like this. This webcam’s have a static focus, so you’re code can’t work on it…
If you want to test this, try to upgrade your cellphone to 4.0, if you need help with you’re galaxy s take a look here: http://forum.xda-developers.com/forumdisplay.php?f=656
I hope you’ll see the problem now!
Best Regards
safari