zxing始终处于横向模式

wmomyfyw  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(350)

我正在尝试实现一个条形码阅读器。https://www.youtube.com/watch?v=wfucgskngq4&list=plybh5yzzegif1dzltufmedfqhysfw1h1i&index=7&t=232s 我遵循了这个教程,几乎所有的工作都很好。我唯一的问题是,它总是在横向屏幕打开,我完全不知道我做错了什么。

butonScanare.setOnClickListener(v -> {
        IntentIntegrator integrator = new IntentIntegrator(activity);
        integrator.setCaptureActivity(CaptureActivity.class);
        integrator.setOrientationLocked(false);
        integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
        integrator.setPrompt("Scanare");
        integrator.initiateScan();
    });

知道我做错什么了吗?

uttx8gqw

uttx8gqw1#

只需将其添加到androidmanifest.xml文件中

<activity
            android:name="com.journeyapps.barcodescanner.CaptureActivity"
            android:screenOrientation="portrait"
            tools:replace="android:screenOrientation"
            android:stateNotNeeded="true"/>

相关问题