首页 > 解决方案 > android中的zxing始终处于横向模式

问题描述

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

任何线索我做错了什么?

标签: javaandroidzxing

解决方案


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

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

推荐阅读