5

I use this snippet to make camera focus on document:

// set focus mode is auto
List<String> supportModes = parameters.getSupportedFocusModes();
// find appreciate focus mode. In this case, the focus mode is 'auto' 
camParameters.setFocusMode(focusmode);

camera.autoFocus(new Camera.AutoFocusCallback() {

@Override
public void onAutoFocus(boolean success, Camera camera) {
    // do something after focusing  
}
});

I put the autoFocus method in a timer, it 's called with 5 seconds interval. My code worked fine on many devices (Galaxy ace, note 3, S3...) except Galaxy S4. From debug, I can see onAutoFocus callback get called, but there is nothing happened with camera and surface view. Camera doesn't focus on anything. The image on surface view is very blur. Does anyone know this bug?

ductran
  • 10,043
  • 19
  • 82
  • 165

1 Answers1

0

Don't you forget the

mCamera.setParameters(camParameters);

after

 camParameters.setFocusMode(focusmode);

?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
mathieu.letombe
  • 343
  • 1
  • 6
  • This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/13821501) – Saeid Sep 29 '16 at 17:47
  • If this line is missing it doesn't work. That may be an answer to the problem! – mathieu.letombe Sep 30 '16 at 13:21