title: Zbar integration into Android app
body: <p>I am using the Android ADT Bundle for dev work. After reading multiple guides online I have added the package com.dm.zbar.android.scanner to my project. I have included the files CameraPreview.java, ZBarConstants.java, and ZBarScannerActivity.java in the package. Despite all this the ZBAR_SCANNER_REQUEST var in the class ScanActivity.java (created by me, but using zbar methods) cannot be resolved to a variable. Everything except this variable is accepted. Any idea why this is occurring? Note: My libs folder contains everything in here: </p>
  
  <p><a href="https://github.com/DushyanthMaguluru/ZBarScanner/tree/master/ZBarScannerLibrary/libs">https://github.com/DushyanthMaguluru/ZBarScanner/tree/master/ZBarScannerLibrary/libs</a></p>
  
  <p>and zbar.jar is included on the build path.</p>
  
  <p><strong>ScanActivity:</strong></p>
  
  <pre><code>package com.xx.xxx;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.content.pm.PackageManager;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Toast;
  import com.dm.zbar.android.scanner.ZBarConstants;
  import com.dm.zbar.android.scanner.ZBarScannerActivity;
  import net.sourceforge.zbar.Symbol;
  
  public class ScanActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_scan);
  }
  
  public void launchScanner(View v) {
      if (isCameraAvailable()) {
          Intent intent = new Intent(this, ZBarScannerActivity.class);
          startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
      } else {
          Toast.makeText(this, "Rear Facing Camera Unavailable", Toast.LENGTH_SHORT).show();
      }
  }
  
  public void launchQRScanner(View v) {
      if (isCameraAvailable()) {
          Intent intent = new Intent(this, ZBarScannerActivity.class);
          intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});
          startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
      } else {
          Toast.makeText(this, "Rear Facing Camera Unavailable", Toast.LENGTH_SHORT).show();
      }
  }
  
  public boolean isCameraAvailable() {
      PackageManager pm = getPackageManager();
      return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      switch (requestCode) {
          case ZBAR_SCANNER_REQUEST:
          case ZBAR_QR_SCANNER_REQUEST:
              if (resultCode == RESULT_OK) {
                  Toast.makeText(this, "Scan Result = " + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_SHORT).show();
              }
              break;
      }
  }
  
  }
  </code></pre>
  
  <p>Just in case it is relevant:
  <strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.xx.xxx"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="17" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
  
  &lt;uses-feature
      android:name="android.hardware.camera"
      android:required="false" /&gt;
  
  &lt;application
      android:icon="@drawable/ic_launcher"
      android:label="xx"
      android:theme="@style/AppTheme" &gt;
      &lt;activity android:name="com.xx.xxx.MainActivity" &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.xx.xxx.WvActivity" /&gt;
      &lt;activity android:name="com.xx.xxx.ScanActivity" /&gt;
      &lt;activity
          android:name="com.dm.zbar.android.scanner.ZBarScannerActivity"
          android:screenOrientation="landscape" /&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>