user1632048
user1632048

Reputation: 9

No activity found to handle intent{act=com.google.zxing.client.android.SCAN cat=

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

Upvotes: 0

Views: 6652

Answers (2)

Roshan Alwis
Roshan Alwis

Reputation: 1

You can resolve this error by installing Google Goggles in your mobile or any kind of supportive bar code scanning application(Zxing Barcode Scanner) . When you try to start the activity it will open through this application and feed data into your android app.

This worked for me :)

Upvotes: -1

Sean Owen
Sean Owen

Reputation: 66866

You do not add android/, or even core/, to your project if you are integrating by Intent. In fact this is strongly discouraged, mostly because of exactly what you've posted above: your app is saying it can handle Intents that Barcode Scanner is supposed to handle. That's not OK -- you're potentially intercepting calls to our app.

Since you are already integrating by Intent, don't bother with any of this. All you need is what is in android-integration/. See http://code.google.com/p/zxing/wiki/ScanningViaIntent

If you use IntentIntegrator as described there, it will handle installing the app so you don't trip over the ActivityNotFoundException you show above.

Upvotes: 1

Related Questions