title: Android Bar code scanner to scan multiple bar code in one shot
body: <p>I'm Using Zbar for bar code scanning and it is working perfect.
  Now what I want is to Scan N numbers of bar code at once or minimum five and show its data in a list.I'have achieved this with button click.
  but I want it to scan bar code continuously.
  <strong>for example :</strong> when we scan any bar code it will scan and saves the data in array, then again it will start to scan bar code.</p>
  
  <blockquote>
    <p>Following code I'm using to scan One Bar code.</p>
  </blockquote>
  
  <pre><code>public class CameraTestActivity extends Activity
  {
  private Camera mCamera;
  private CameraPreview mPreview;
  private Handler autoFocusHandler;
  TextView scanText;
  Button scanButton;
  ImageScanner scanner;
  private boolean barcodeScanned = false;
  private boolean previewing = true;
  static {
  System.loadLibrary("iconv");
  } 
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  autoFocusHandler = new Handler();
  mCamera = getCameraInstance();
  /* Instance barcode scanner */
  scanner = new ImageScanner();
  scanner.setConfig(0, Config.X_DENSITY, 3);
  scanner.setConfig(0, Config.Y_DENSITY, 3);
  mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
  FrameLayout preview = (FrameLayout)findViewById(R.id.cameraPreview);
  preview.addView(mPreview);
  scanText = (TextView)findViewById(R.id.scanText);
  scanButton = (Button)findViewById(R.id.ScanButton);
  if (barcodeScanned) {
  barcodeScanned = false;
  scanText.setText("Scanning...");
  mCamera.setPreviewCallback(previewCb);
  mCamera.startPreview();
  previewing = true;
  mCamera.autoFocus(autoFocusCB);
  }
  scanButton.setOnClickListener(new OnClickListener() {
  public void onClick(View v) {
  if (barcodeScanned) {
  barcodeScanned = false;
  scanText.setText("Scanning...");
  mCamera.setPreviewCallback(previewCb);
  mCamera.startPreview();
  previewing = true;
  mCamera.autoFocus(autoFocusCB);
  }
  }
  });
  }
  public void onPause() {
  super.onPause();
  releaseCamera();
  }
  /** A safe way to get an instance of the Camera object. */
  public static Camera getCameraInstance(){
  Camera c = null;
  try {
  c = Camera.open();
  } catch (Exception e){
  }
  return c;
  }
  private void releaseCamera() {
  if (mCamera != null) {
  previewing = false;
  mCamera.setPreviewCallback(null);
  mCamera.release();
  mCamera = null;
  }
  }
  private Runnable doAutoFocus = new Runnable() {
  public void run() {
  if (previewing)
  mCamera.autoFocus(autoFocusCB);
  }
  };
  PreviewCallback previewCb = new PreviewCallback() {
  public void onPreviewFrame(byte[] data, Camera camera) {
  Camera.Parameters parameters = camera.getParameters();
  Size size = parameters.getPreviewSize(); 
  Image barcode = new Image(size.width, size.height, "Y800");
  barcode.setData(data);
  int result = scanner.scanImage(barcode);
  if (result != 0) {
  previewing = false;
  mCamera.setPreviewCallback(null);
  mCamera.stopPreview();
  SymbolSet syms = scanner.getResults();
  for (Symbol sym : syms) {
  scanText.setText("barcode result " + sym.getData());
  scanButton.setVisibility(View.VISIBLE);
  barcodeScanned = true;
  }
  }
  }
  };
  // Mimic continuous auto-focusing
  AutoFocusCallback autoFocusCB = new AutoFocusCallback() {
  public void onAutoFocus(boolean success, Camera camera) {
  autoFocusHandler.postDelayed(doAutoFocus, 1000);
  }
  };
  }
  </code></pre>