Question

I've encountered a strange issue, specifically on a Nexus 4 (though it may exist on other devices), where the camera flash won't fire when the focus mode is set to FOCUS_MODE_CONTINUOUS_PICTURE. The same code works fine on a Galaxy Nexus running the same version of Android (4.2.1). Has anyone encountered this problem before? I can fix the issue by simply switching the focus mode to FOCUS_MODE_AUTO. I'm hoping there is an easy work around for this issue, since the continuous picture focus mode is pretty crucial.

Était-ce utile?

La solution

(For what it's worth just wrapping up my comment in an answer.)

The reason I suspect that continuous focus doesn't work on the Nexus 4 is that I have heard some rumblings from the Barcode Scanner user base about this (I'm the author). The Nexus 4 doesn't seem to work with, or without continuous focus enabled.

I haven't seen more detail to confirm/deny this, but, I have certainly seen this exact form of problem on other devices. In particular the Galaxy S2 seems to have some bad focus bugs.

It manifests as something slightly different: there is some third parameter you are setting which should be supported, or says it's supported, but actually causes the driver to barf. Then it doesn't honor the focus or torch setting. It may be that continuous focus, and torch, work. But a third setting is tripping it up.

Look into the logcat output. You should see debug messages from the driver. The exact nature depends a lot on the firmware. But in cases like this you will likely see errors in the driver. I usually see "unsupported parameter X" and cryptic numbers; sometimes it's much clearer about what it didn't like.

This may give you a lead, that it is in fact something like scene mode or metering area that are the problem. (And I have seen each of those cause this problem on at least one device.)

I also have a Galaxy Nexus and have never observed any problems of this form on it.

I'll also say that continuous focus can work nicely on some devices; it is worse on some devices like my old Desire HD, than the simple auto-focus mode. YMMV; I concluded it wasn't necessarily helpful so made regular auto focus the default in Barcode Scanner.

Autres conseils

There are lot of issues on camera on Nexsus 4.

Firstly please try parameters.getSupportedFocusModes()

To restore continues autofocus, just call "cancelAutoFocus()" on the camera in your "AutoFocusCallback.java",

{
if (autoFocusHandler != null) {
  camera.cancelAutoFocus(); 
  ...
}

This call has no effect if the focus mode is "FOCUS_MODE_AUTO", because the the autofocus is finished anyway when onAutoFocus() gets called. But it restores the continuous autofocus when "FOCUS_MODE_CONTINUOUS_PICTURE" is used.

Hope it helps.I will work more and update.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top