What needs to be added to the android manifest file for the zxing barcode scanner?

后端 未结 2 1841
迷失自我
迷失自我 2021-01-28 16:07

I have used Intent to integrate the zxing barcode scanner into my application but i am lost on what needs to be in the manifest. As of right now when i click on the button to la

相关标签:
2条回答
  • 2021-01-28 16:29

    The ZXing project provides some code for calling XZing via an Intent on their Wiki:

    http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java

    If you're using that code, you don't need to add anything to your manifest file. From your activity you can just call

    IntentIntegrator.initiateScan(this);
    

    That will take care of verifying that ZXing is installed, and prompt the user to install it via the Marketplace if it isn't.

    0 讨论(0)
  • 2021-01-28 16:46

    Do you want to call the installed Barcode Scanner app? I did the same a week ago.

    Here's my code:

    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
    startActivityForResult(intent, 0);
    

    AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="de.myPackage"
          android:versionCode="1"
          android:versionName="1.0">
        <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".MyApp"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
        </application>
    
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    </manifest>
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题