android 中的 Zxing 始终处于横向模式

Zxing in android always in landscape mode

我正在尝试实现条形码 reader。 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();
    });

知道我做错了什么吗?

只需将其添加到您的 AndroidManifest.xml 文件中

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