Getting android.content.ActivityNotFoundException with Zxing

admin

Administrator
Staff member
I have followed the following tutorial : <a href="http://damianflannery.wordpress.com...into-your-android-app-natively-using-eclipse/" rel="nofollow">http://damianflannery.wordpress.com...into-your-android-app-natively-using-eclipse/</a>

But even after editing android manifest xml as told there I am getting the following error:

Code:
 android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.SCAN pkg=com.google.zxing.client.android (has extras) }

My Code :

Code:
 public class BarCodeScannerActivity extends Activity {  
        /** Called when the activity is first created. */  
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);  
            setContentView(R.layout.main);  


        Button ok;  

       ok=(Button) findViewById(R.id.b1);  
       ok.setOnClickListener(new View.OnClickListener()  
         {

           public void onClick(View v) {   
              // TODO Auto-generated method stub 
              System.out.println("Helllllllloooooooo");
              Intent intent = new Intent("com.google.zxing.client.android.SCAN");  
            intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE","QR_CODE_MODE");       
                startActivityForResult(intent, 0);   

        }
    });
        }

     public void onActivityResult(int requestCode, int resultCode, Intent intent) {             
    System.out.println("onActivityResult________resultCode________ "+resultCode);   

    if (requestCode == 0) {   
        if (resultCode == RESULT_OK) {    
            String contents = intent.getStringExtra("SCAN_RESULT"); 
            System.out.println("contentsssssssssssssssssssssss" + contents);
            Toast.makeText(getApplicationContext(),"Congratulations!!!... Product Code"+ contents + "On Scanning This Item..." ,Toast.LENGTH_LONG).show();  

            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");   
            System.out.println("Formaattttttttttttttt " + format);
            // Handle successful scan      
        }   else if (resultCode == RESULT_CANCELED) {   
            // Handle cancel       
          }    
      } 
  }
  }

And mainfest file:





Code:
&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
    &lt;activity android:name=".BarCodeScannerActivity"
              android:label="@string/app_name"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;



    &lt;/activity&gt;


    &lt;activity android:name="com.google.zxing.client.android.CaptureActivity"
    android:screenOrientation="landscape"
    android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    android:windowSoftInputMode="stateAlwaysHidden"&gt;

    &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;


        &lt;intent-filter&gt;
            &lt;action android:name="com.google.zxing.client.android.SCAN" /&gt;
            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
        &lt;/intent-filter&gt;

    &lt;/activity&gt;





&lt;/application&gt;

&lt;uses-permission android:name="android.permission.CAMERA" /&gt;



Hi

Now i am getting a strange problem of attached screen shot once i updated my manifest as follows:

Code:
&lt;activity android:name="com.google.zxing.client.android.CaptureActivity"  
              android:screenOrientation="landscape"  
              android:configChanges="orientation|keyboardHidden"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
             android:windowSoftInputMode="stateAlwaysHidden"&gt;
  &lt;intent-filter&gt;
    &lt;action android:name="android.intent.action.MAIN"/&gt;  
    &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
  &lt;/intent-filter&gt;
  &lt;intent-filter&gt;
    &lt;action android:name="com.google.zxing.client.android.SCAN"/&gt;
    &lt;category android:name="android.intent.category.DEFAULT"/&gt;
  &lt;/intent-filter&gt;
  &lt;/activity&gt;
![enter image description here][1]
&lt;activity android:name=".ScanItemActivity"
        android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:windowSoftInputMode="stateAlwaysHidden"&gt;
        &lt;/activity&gt;

I mean it says ""Sorry, the Android camera encountered a problem. You may need to
restart the device."

Nothing is there in logcat.