二维码扫描

发布于 2024-12-09 11:05:34 字数 408 浏览 6 评论 0原文

我根据帖子 直接集成 ZXing 库添加了 ZXing 的核心 jar 文件进入我的 Android 应用程序

在我的应用程序中,我试图创建一个根据帖子启动 QR 阅读器的意图 二维码扫描仪

但是我在 core.jar 中找不到 CaptureActivity 类?

如何在不使用任何外部应用程序的情况下读取应用程序中的二维码?

谢谢, 埃亚尔。

I have added core jar file of ZXing according to post Integrating the ZXing library directly into my Android application

in my application i'm trying to create an intent that starts the QR reader according to post
QR code scanner

But i can not find the CaptureActivity class in the core.jar?

How can I read QR code within my application without using any external application?

Thanks,
Eyal.

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

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

发布评论

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

评论(2

酒与心事 2024-12-16 11:05:34

CaptureActivity 应该在那里,只是如果您想运行它,您仍然必须将其添加到 AndroidManifest.xml 中,因为这不会从 jar 中继承。添加此 XML

<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
  <action android:name="com.google.zxing.client.android.SCAN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

参考:http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/

(是,我自己尝试过)

也确保你有

<uses-permission android:name="android.permission.CAMERA"/>

CaptureActivity should be there, it's just that you still have to add it to AndroidManifest.xml if you want to run it because that won't carry over from the jar. Add this XML

<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
  <action android:name="com.google.zxing.client.android.SCAN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

Reference: http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/

(Yes, I have tried this myself)

also make sure you have

<uses-permission android:name="android.permission.CAMERA"/>
虫児飞 2024-12-16 11:05:34

您所做的一切都是正确的——除了您不应该使用CaptureActivity。未找到它,因为它不是 core/ 库的一部分,而是 android/ 的一部分,它是我们的应用程序 Barcode Scanner 的源代码。我建议不要直接重用我们的代码,因为您必须复制大量代码才能使其正常工作,而大多数走这条路的人只是复制几乎所有内容,这是不行的。

您需要编写自己的应用程序。看看android/中的代码如何调用DecodeHandler中的核心库进行解码。您可以查看我们的 AndroidManifest.xml 以了解如何声明您的意图。您不需要也不应该复制我们的CaptureActivity。它的存在是为了好的想法,而不是克隆。

You're doing everything right -- except that you should not be using CaptureActivity. It's not found since it's not part of the core/ library, but rather part of android/, which is the source for our app, Barcode Scanner. I'd suggest not reusing our code quite that directly, since you will have to copy a lot to get it to work, and most people who go this route just copy nearly everything, and that's not OK.

You need to write your own application. See how the code in android/ calls the core library for decoding in DecodeHandler. You can look at our AndroidManifest.xml to see how to declare your intents. You do not need to, and should not, copy our CaptureActivity. It's there for good ideas, not cloning.

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