Zxing条码扫描器集成了外部条码扫描器应用程序

0 integration android qr-code barcode zxing

我正在尝试将zxing条形码扫描仪集成到我的应用程序中.一切都按计划进行,只有当我点击扫描时,它才会要求我从集成或外部选择.我可以避免这个问题吗?

对于项目:我没有将其作为库导入,我将所有java代码文件放入项目中.这是我们的要求之一.我们不希望应用程序依赖任何外部资源(即使它们只是内部资源)

我还在Android设备上测试了它,它没有zxing条形码扫描器.没问题.

我怎样才能买到这个问题并指出内部版本?

这是调用它的代码:

button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
            startActivityForResult(intent, 0);
        }
    });
Run Code Online (Sandbox Code Playgroud)

我还试图找到com.google.zxing.client.android.SCAN类但找不到它.但有趣的是,它有效.

这是清单的一部分:

    <activity android:name="com.google.zxing.client.android.CaptureActivity"
       android:screenOrientation="landscape"
       android:configChanges="orientation|keyboardHidden"
       android:theme="@android:style/Theme"
       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>
Run Code Online (Sandbox Code Playgroud)

关于我遵循的集成代码:

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

我真的不知道自己做错了什么.^^

Com*_*are 7

这是调用它的代码

您正尝试使用的操作启动活动com.google.zxing.client.android.SCAN.任何给定的设备都可以包含任意数量的设备,包括标准条形码扫描仪应用程序.

因此,而不是:

Intent intent = new Intent("com.google.zxing.client.android.SCAN"); 
Run Code Online (Sandbox Code Playgroud)

你应该使用:

Intent intent = new Intent(this, com.google.zxing.client.android.CaptureActivity.class); 
Run Code Online (Sandbox Code Playgroud)

而且,由于您不是条形码扫描仪,因此您应该清除清单中的<intent-filter>元素CaptureActivity.