做了一个应用,其中需要调用摄像头扫描条码,这里采用的zxing的code,但是这需要依赖于用户先安装BarcodeScanner,尽管程序可以做到当发现没有安装BarcodeScanner的时候,会提示用户下载,但是总是觉得用户体验不好,有没有谁知道应该怎样将zxing的JAR包添加到应用中,而不用提示用户下载,zxing编译后的jar包我已经有

解决方案 »

  1.   

    buildpath喽,就是不知道为什么中文识别出来是乱码!!
       恨死乱码,草!!!!!!!
      

  2.   

    简化定制自己的Zxing库。详见
    http://www.cnblogs.com/goin/archive/2011/06/10/2078007.html
      

  3.   

    把zxing源码下下来,源码里面有一个示例,你可以模仿着做出来。我以前就实现过LZ所说的功能
      

  4.   

    有两个办法。
    1. 你自己简化ZXing中自带的那个android client
    2. 如果不想自己去简化(有点烦的),那么就严格按照下面的说法去做:
    Edit: Sean Owen, one of the developers for ZXing has posted a comment to this blog warning of the pitfalls of integrating ZXing into your own app; doing so just to avoid having your users take that extra step of installing from the et is not a good reason. I completely agree with this. There are many advantages to using the intent based approach as outlined in his comments. My motivation is for an enterprise app that does not have access to the Android et and involves my client installing zxing manually on thousands of devices before they are able to distribute to its business customers.So to be clear, do not use this method unless it is absolutely necessary, and if you do have to – make sure that override your intent filters so that other apps that want to use zxing do not end up calling your modified version. Also, if zxing is already installed, then you should use that by default instead of your modified version.ZXing is one of the most popular barcode scanning applications on the et. They make it very easy for you to integrate into your application via an intent but this means that your users must manually install the application from the et.Fortunately, the app is also open source so I will show you how to cleanly build this capability into your project.Please note that the awesome developers of this product have released the src under the Apache v2.o license so please be sure to adhere to the terms of this license and give them full credit for their work. http://www.apache.org/licenses/LICENSE-2.0Step One: Obtain the zxing src code
    The src can be found at http://code.google.com/p/zxing/source/browse/trunk. Specifically you only need the android/ and the core/ projects. Use svn to checkout these to your local hard-drive.Step Two: Build zxing core using Apache Ant
    You will need to build the core project into a jar file using apache ant (download from here http://ant.apache.org/ivy/download.cgi). Using a shell or cmd prompt navigate to the root directory of the downloaded zxing src and execute ”ant -f core/build.xml”. This will produce a file core/core.jar which we will use in the next step.Step Three: Build ZXing Android using Eclipse
    Create a New Android Project (File –> New –> Android Project).
    Set the project name to ZXing (or similar).
    Select the “Create project from existing source” radio button
    Click “Browse” and navigate to the android project that you downloaded from zxing and click “OK”
    Select “Finish”The project will not currently build. We need to add the core.jar file (that we produced in the previous step) into our project. Right-click on ZXing project –> properties –> Java Build Path –> Add External Jars –> Navigate to and select core.jar –> Open –> OK.Actually, while we’re here we should do one more very important thing! Right-click on ZXing project –> properties –> Android –> Scroll down and check/tick the “Is Library” checkbox –> OK.Step 4: Include ZXing Android into your project.
    Within Eclipse,  Right-click on YOURPROJECTNAMEHERE project –> properties –>Android –> Scroll down to Libraries section –> Click Add –> Select ZXing (which should appear as an option as a result of completing previous step).Next, in some trigger function e.g. button press within your code you should add:1 Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    2 intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
    3 startActivityForResult(intent, 0);In the same activity you’ll need the following to retrieve the results:01 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    02    if (requestCode == 0) {
    03       if (resultCode == RESULT_OK) {
    04          String contents = intent.getStringExtra("SCAN_RESULT");
    05          String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
    06          // Handle successful scan
    07       } else if (resultCode == RESULT_CANCELED) {
    08          // Handle cancel
    09       }
    10    }
    11 }Almost there! One of the current limitations of Android Library projects is that it will not pull anything from AndroidManifest.xml into your project.
    So if we try to invoke the above code we will receive a runtime exception because your Android app has no idea how to handle the scan intent.
    To fix this you just need to copy the following into your AndroidManifest.xml:01 <activity android:name="com.google.zxing.client.android.CaptureActivity"
    02    android:screenOrientation="landscape"
    03    android:configChanges="orientation|keyboardHidden"
    04    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    05    android:windowSoftInputMode="stateAlwaysHidden">
    06    <intent-filter>
    07       <action android:name="android.intent.action.MAIN"/>
    08       <category android:name="android.intent.category.DEFAULT"/>
    09    </intent-filter>
    10    <intent-filter>
    11       <action android:name="com.google.zxing.client.android.SCAN"/>
    12       <category android:name="android.intent.category.DEFAULT"/>
    13     </intent-filter>
    14 </activity>And as Columbo would say, “Just one more thing!”. Add this permission to the top of your AndroidManifest.xml:1 <uses-permission android:name="android.permission.CAMERA"/>EDIT: You need to do yet one more thing! You need to add the core.jar (produced in Step two) to your new project (Right-click your project –> Properties –> Java Build Path –> Add External JARS… –> Select core.jar –> OK). Thanks to Marco and Markosys in the comments for spotting and pointing out the omission!
      

  5.   

    求楼主的zxing编译后的jar···  邮箱:[email protected]
      

  6.   


    自己动手吧,不难得的。另外这个核心源码没法处理中文,都是一堆乱麻,必须手工改写core核心源码文件后再去编译。
      

  7.   

    lz你解决了这个问题了吗?最近我也在弄这个 也要额外安装这个apk,lz是怎么解决的呢?求帮忙