问题描述
我读过无数话题已经在那里的人问到如何ZXing在Android应用程序集成,他们不一定需要安装才能扫描QR code第三方扫描应用程序。
I've read numerous topics already where people asked how to integrate ZXing in an Android application where they necessarily need to have a 3rd party scanner app installed in order to scan a QR Code.
这正是我想做的事情了。这是我迄今所做的:
That's exactly what i want to do too. This is what i have done so far:
我下载斑马线项目。我复制了所有相关的源$ C $ C到我的Android应用程序。到目前为止好,这一切编译罚款。当我美元,我的应用程序一个按钮p $ PSS它会打开一个小对话框,询问code扫描我想用什么样吧。我有以下选择:
I downloaded the ZXing project. I copied all the relevant source code to my Android application. So far so good, it all compiles fine. When i press on a button in my app it opens a small dialog asking what barcode scanner i want to use. I have the following options:
- QR-的Droid(第三方应用程序)
- 我自己的应用程序
当我使用第一个选项,然后相机被激活,我可以扫描QR code。但是当我使用第二个选项(我自己的应用程序),然后什么happends。我以为ZXing想出了一个扫描仪也使第三方QR扫描没有必要?
When i use the first option, then the camera gets activated and i can scan a QR code. But when i use the 2nd option (my own app), then nothing happends. I thought ZXing came with a scanner too, so that a 3rd party QR scanner isn't necessary??
但也许还有其他的步骤,我必须采取藏汉?这是我的表现怎么是这样的:
But maybe there are other steps i have to take aswell? This is how my manifest looks like:
补充这一点:
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
而在一个按钮动作,我有:
And in a button action i have:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
有没有什么办法让无需第三方扫描仪的QR扫描的开始?我所有的消息在我的项目。
Is there any way to make a QR Scanner start without the need of a 3rd party scanner?? I have all the source imported in my project.
推荐答案
修改您的清单,并添加此
Modify your Manifest and add this
<activity
android:configChanges="orientation|keyboardHidden"
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
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>
还添加了摄像头权限
also add camera permission
<uses-permission android:name="android.permission.CAMERA"/>
和你的活动implemetn的onActivityResult方法
and implemetn onActivityResult method in your Activity
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if (requestCode == 0)
{
if (resultCode == RESULT_OK)
{
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
Log.i("xZing", "contents: "+contents+" format: "+format);
// Handle successful scan
}
else if (resultCode == RESULT_CANCELED)
{
// Handle cancel
}
}
}
了解更多信息或有任何问题请参见<一个href=\"http://damianflannery.word$p$pss.com/2011/06/13/integrate-zxing-bar$c$c-scanner-into-your-android-app-natively-using-eclipse/\"相对=nofollow>此链接
这篇关于整合ZXing无需使用第三方扫描器的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!