0

I got: android.content.ActivityNotFoundException: No activity found to handle intent{ act=com.google.zxing.client.android.SCAN cat=[android.intent.category.DEFAULT] flg=0x4080000 pkg=com.google.zxing.client.android} when I run my own app integrated with zxing barcode scanner. There is no logcat.

First of all I downloaded source code from zxing and build it into an app and runs fine, then I turn it into a library for my app and run my app then got the error above. Here are how to turn zxing barcode scanner into a lib for my app:

I. on myapp's AndroidManifest.xml, add

<activity android:name="com.google.zxing.client.android.CaptureActivity"
      android:screenOrientation="landscape"
      android:clearTaskOnLaunch="true"
      android:stateNotNeeded="true"
      android:configChanges="orientation|keyboardHidden"
      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
      android:windowSoftInputMode="stateAlwaysHidden">
        <intent-filter>
        <action android:name="com.google.zxing.client.android.SCAN"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>        

II. on myapp's MainActivity.java, I have this piece of code:

      String package_name="com.google.zxing.client.android";

      Intent iScan = new Intent(package_name+".SCAN");

      iScan.setPackage(package_name);

      iScan.addCategory(Intent.CATEGORY_DEFAULT);

      iScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

      iScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

      iScan.putExtra("SCAN_WIDTH", 420);

      iScan.putExtra("SCAN_HEIGHT", 420);

      iScan.putExtra("RESULT_DISPLAY_DURATION_MS", 3000L);

      iScan.putExtra("SCAN_MODE", "QR_CODE_MODE");

      iScan.putExtra("PROMPT_MESSAGE", "Scan the Contact");

           startActivityForResult(iScan, 0);      

III. On my Project Properties->Android,

add  com.google.xing.client.android as lib and copy 

com.google.xing.client.android.captureactivity.jar core.jar to libs dir of my app

4

2 に答える 2

1

Intent で統合している場合は、プロジェクトに を追加したり、 をandroid/追加したりしません。core/実際、これは主にあなたが上に投稿したこととまったく同じため、強くお勧めできません。あなたのアプリは、バーコード スキャナーが処理するはずのインテントを処理できると言っています。それは問題です。アプリへの呼び出しを傍受している可能性があります。

既に Intent で統合しているので、気にしないでください。必要なのは にあるものだけですandroid-integration/http://code.google.com/p/zxing/wiki/ScanningViaIntentを参照してください

そこで説明されているように使用IntentIntegratorすると、アプリのインストールが処理されるため、ActivityNotFoundException上記の表示につまずくことはありません。

于 2012-08-31T18:08:19.673 に答える