Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autofocus can't be set from code #11

Open
Llorc opened this issue Dec 21, 2017 · 0 comments
Open

autofocus can't be set from code #11

Llorc opened this issue Dec 21, 2017 · 0 comments

Comments

@Llorc
Copy link

Llorc commented Dec 21, 2017

Actually (info.androidhive:barcode-reader:1.1.5), the autofocus can't be set from code.
Can you add something like setAutofocus(true/false) ?

If that can help, now I use this workaround:

     public static class BarcodeReaderEx extends BarcodeReader{
        public BarcodeReaderEx(){
            super();
            setAutofocus(true);
        }
        public void setAutofocus(boolean autofocus){
            //this.autoFocus = autofocus;
            try {
                Field f = BarcodeReader.class.getDeclaredField("autoFocus"); //NoSuchFieldException
                f.setAccessible(true);
                f.setBoolean(this,autofocus);
                //Boolean af = (Boolean) f.get(this); //IllegalAccessException
            }catch(Exception ignore){

            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant