Another light hack attempt to work around Issue 70

git-svn-id: https://zxing.googlecode.com/svn/trunk@541 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-07-31 19:21:34 +00:00
parent 3ab723c0c4
commit 9e65557e47

View file

@ -19,6 +19,7 @@ package com.google.zxing.client.j2me;
import javax.microedition.amms.control.camera.ExposureControl;
import javax.microedition.amms.control.camera.FocusControl;
import javax.microedition.amms.control.camera.ZoomControl;
import javax.microedition.media.Control;
import javax.microedition.media.Controllable;
import javax.microedition.media.MediaException;
@ -36,6 +37,21 @@ final class AdvancedMultimediaManager implements MultimediaManager {
private static final long FOCUS_TIME_MS = 750L;
private static final String DESIRED_METERING = "center-weighted";
AdvancedMultimediaManager() {
// Another try at fixing Issue 70. Seems like FocusControl et al. are sometimes not
// loaded until first use in the setFocus() method. This is too late for our
// mechanism to handle, since it is trying to detect this API is not available
// at the time this class is instantiated. We can't move the player.getControl() calls
// into here since we don't have a Controllable to call on, since we can't pass an
// arg into the constructor, since we can't do that in J2ME when instantiating via
// newInstance(). So we just try writing some dead code here to induce the VM to
// definitely load the classes now:
Control dummy = null;
ExposureControl dummy1 = (ExposureControl) dummy;
FocusControl dummy2 = (FocusControl) dummy;
ZoomControl dummy3 = (ZoomControl) dummy;
}
public void setFocus(Controllable player) {
FocusControl focusControl = (FocusControl)
player.getControl("javax.microedition.amms.control.camera.FocusControl");