zxing 集成到 monodroid 应用程序中
我正在尝试将 ZXing 的条形码扫描仪集成到 MonoDroid 应用程序中。我看到普通的Android(java)应用程序有IntentIntegration.java 和 IntentResult.java 包含到他们的项目中以提供帮助。我想知道是否有人将它们移植到.NET(我没有看到它们移植到 csharp 项目中。)?我还想知道是否有人以另一种方式实现了 ZXing 来使用他们的应用程序?如果有人与 MonoDroid 集成,需要做什么才能在按钮单击处理程序中启动扫描?
另外,如果有人有任何其他可以实施的 3 方条形码扫描仪,请在评论中提出这些建议。
I'm trying to integrate ZXing's barcode scanner into a MonoDroid application. I see that normal Android (java) apps have IntentIntegration.java and IntentResult.java to include into their project to help. I was wondering if anyone has ported those to .NET (I didn't see them ported in the csharp project.)? I'm also wondering if anyone has implemented ZXing in another way to get to work with their app? If anyone has integrated with MonoDroid, what needs to be done to initiate a scan in a button click handler?
Also, if anyone has any other 3 party barcode scanner that could be implemented instead, put those suggestions in the comments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个问题是,您真的需要移植这些文件吗? :-)
您可以将 Java 源代码包含到 Mono for Android 项目中;只需将“构建”操作设置为
AndroidJavaSource
,源代码就会被编译到生成的 .apk 中。这也可以通过.jar
文件来完成。接下来就是从C#调用Java代码的问题。
对于
IntentIntegration.java
和IntentResult.java
,可能就足够了,因为这些类型不支持继承(它们是最终
)。当然,使用 JNIEnv 调用它们上的方法将是一个 PITA,但它可以做到:此外,
IntentIntegrator
文档提到提供的 Activity 必须覆盖 Activity.OnActivityResult 方法。尽管如此,移植
IntentIntegrator.java
应该不会那么困难,因为它的大部分都是 Activity.StartActivityForResult 具有适当的意图和构造AlertDialog
(您可能需要也可能不需要)。The first question is, do you actually need to port those files? :-)
You can include Java source code into a Mono for Android project; just set the Build action to
AndroidJavaSource
and the source will be compiled into the resulting .apk. This can also be done with.jar
files.Then comes the question of invoking the Java code from C#.
In the case of
IntentIntegration.java
andIntentResult.java
, that may be enough, as those types don't support inheritance (they'refinal
). Granted, using JNIEnv to invoke methods on them would be a PITA, but it can be done:Furthermore, the
IntentIntegrator
docs mention that the Activity provided must override the Activity.OnActivityResult method.All that said, porting
IntentIntegrator.java
shouldn't be that difficult, as most of it is a wrapper over Activity.StartActivityForResult with an appropriate intent and construction of anAlertDialog
(which you may or may not need).我们现在有用于
MonoTouch
和Monodroid
的ZXing
端口。https://github.com/Redth/ZXing.Net.Mobile
We now have
ZXing
ports forMonoTouch
andMonodroid
.https://github.com/Redth/ZXing.Net.Mobile