如何在 Java、Android 上从 ZXing 源执行条形码扫描仪?
我刚刚使用条形码扫描仪(ZXing 1.7)提出了申请。用户不在他的手机上使用条形码扫描仪,因此我无法将外部条形码扫描仪添加到我的应用程序中。我已将 ZXing 源添加到我的项目中,但我不知道如何在没有意图的情况下执行它。请帮我。
更新:或者如何使外部条形码扫描仪自动随我的应用程序安装?
I have just made application using BarCode scanner (ZXing 1.7). User doesn't use bar code scanner on his phone, therefore I can't add external Bar Code scanner into my application. I have added ZXing sources for into my project, but I don't know how I can execute it without intents. Please, help me.
Update: or how can I make that external bar code scanner will be installed automatically with my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法安装要自动安装的外部条码扫描仪。您可以做的是检查它是否已安装,如果没有显示一个对话框,询问用户是否要安装它(这会将用户带到应用程序市场链接)。
如果你想避免这种情况,你可以直接集成ZXing库,但这需要更多的工作。条形码扫描仪应用程序是开源的,因此您可以从那里了解如何操作。
You can't install the external barcode scanner to be installed automatically. What you could do is to check if it is installed, and if not show a dialog asking the user wether they want to install it (this will take the user to the app market link).
If you want to avoid this, you can integrate directly the ZXing library but it requires more work. The barcode scanner app is open source so you can see how to do it from there.
如果手机中安装了zxing条码扫描器,则非常简单:
在
OnActivityResult
中:如果未安装:您可以将此代码放在try-catch块中并捕获异常,您可以这样做:
因此,它将应用程序重定向到 Android 市场,并且如果安装了条形码扫描仪,您的应用程序将继续运行一次。
如果你不想在你的应用程序中使用其他应用程序,你必须下载 zxing 库并尝试使用 core.jar 文件中的类(它是使用 apache ant 创建的)。请按照本教程执行此操作:
http://code.google.com/p/zxing/wiki/GettingStarted
If the zxing barcode scanner is installed in the mobile, its very easy:
and in
OnActivityResult
:If its not installed: u can put this code in try-catch block and catching the exception, u can do this:
So it redirects the app to android market and ur app continues running once if the barcode scanner is installed.
If u dont want to use the other app in ur app, U have to download zxing library and try using the classes from core.jar file(it is created using apache ant). Follow this tutorial to do that:
http://code.google.com/p/zxing/wiki/GettingStarted
只需使用提供的基于 Intent 的集成代码即可。这很容易。它将把用户发送到市场来下载应用程序。这比尝试自动安装要好得多,原因至少有三个。首先,我认为用户不希望应用程序安装其他应用程序,并且可能不喜欢它。其次,只有当用户将设备设置为允许来自外部市场的第三方应用程序时,它才可能起作用。最后,您将安装一个可能旧的版本。
Just use the provided Intent-based integration code. It's very easy. It will send the user to Market to download the app. This is much better than trying to automatically install it for at least three reasons. First, I do not think users expect apps to install other apps and probably don't like it. Second it will only possibly work if the user has set the device to allow third-party apps from outside Market. Finally, you will be installing a potentially old version.