为什么在 captureAcitivity 之前执行 Activity 时 ZXing 会出现黑屏

发布于 2024-12-29 14:04:08 字数 396 浏览 4 评论 0原文

我使用 ZXing 扫描条形码,但我有一个问题: 如果我制作加载屏幕并使用处理程序启动 CaptureActivity 它工作得很好。

但是如果我有其他活动,例如 MainMenu 活动。当我通过主菜单上的按钮启动CaptureActivity后,条形码扫描仪给我一个黑屏,就像关闭的相机或其他东西一样。

请帮忙。 预先非常感谢您。

更新:在屏幕的 4 个角上将看到来自相机的光线。如果用手靠近相机,四个角会变黑。但只有角落里有一些空间。

UPDATE2:我发现,如果我在启动 CaptureActivity 之前在活动中物理地改变方向,则应用程序可以正常工作。这很奇怪,但却是事实。但我每次使用应用程序时都需要这样做吗?请帮忙。非常感谢你。

I use ZXing to scan barcode but I have a problem that:
If I make load screen and use handler to start CaptureActivity It's work very fine.

But If I have other activity such as a MainMenu Activity. after I start CaptureActivity through the button on mainmenu the barcode scaner give me a black screen like a shut down camera or sth.

please help.
Thanks you very much in advance.

UPDATE: on the 4 corners of screen will see light from camera. if you use your hand close the camera 4 corners will became black. but just a few space on corners only.

UPDATE2: I found that if i change orientation physically in the activity before start CaptureActivity the app work fine. It weird but true. but I need to do this every time i use app? Please help. Thanks you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁拥 2025-01-05 14:04:08

您需要授予应用程序使用摄像头的权限,否则屏幕会黑屏。
为此,请打开 Android 清单文件并添加相机选项。

You need to give the application permission to use the camera otherwise the screen will be black.
To do this, open the android manifest file and add the camera option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文