java - 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();
});
任何线索我做错了什么?
解决方案
只需将其添加到您的 AndroidManifest.xml 文件中
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"/>
推荐阅读
- python - 我在这个脚本中遇到错误,在 tkinter 显示器上什么都看不到
- r - \xe8 匹配 str_detect() 和 str_replace_all() 中的 \xf1
- r - 在 r 中粘贴具有条件的列元素
- rest - 使用带有 REST 的 MarkLogic 搜索 API 仅提取数据(没有响应元素)
- android - Exo PlayerView 第一帧拉伸到全屏
- python - 将音频文件保存到所需路径
- flutter - 运行天气应用程序时出现此错误我正在使用 json 和 http 库来获取数据但我不知道为什么会出现此错误
- mysql - Spring Data JPA - 悲观锁定不起作用
- pandas - Pandas - 计算平均值并在新列中添加值
- javascript - 未捕获的错误 typeerror calendar.fullcalendar 不是函数