public void scanNow() {
   IntentIntegrator integrator = new IntentIntegrator(this);
   integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
   integrator.setPrompt("Scan a barcode");
   integrator.setResultDisplayDuration(0);
   integrator.setWide(); // Wide scanning rectangle, may work better for 1D barcodes
   integrator.setCameraId(0); // Use a specific camera of the device
   integrator.initiateScan();
 }
  /**
   * event handler for scan button instantiates an instance of the Intent Integrator and send an
   * Intent to the barcode scanner of the device.
   *
   * @param view view of the activity
   */
  public void scanQR(View view) {

    // create an instance of the integrator class which
    // will send the scan intent to the devices barcode scanner
    IntentIntegrator integrator = new IntentIntegrator(this);
    // sets the type of code that will be scanned
    integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
    integrator.setPrompt(String.valueOf(R.string.txt_scan_qrcode));
    integrator.setResultDisplayDuration(0);
    integrator.setCameraId(0); // Use a specific camera of the device
    integrator.initiateScan(); // starts the scan
  }
Exemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bar_code);

    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setCaptureActivity(AnyOrientationCaptureActivity.class);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
    integrator.setPrompt("Scan something"); // Optional- take out or change if needed
    integrator.setOrientationLocked(false); // Scanning can be done in any orientation
    integrator.setBeepEnabled(false);
    integrator.initiateScan();
  }
Exemplo n.º 4
0
  private void scanBarcode() {

    // create the intent integrator to scan in the current fragment
    IntentIntegrator integrator = IntentIntegrator.forSupportFragment(this);

    // use a custom scanactivity that can be rotated
    integrator.setCaptureActivity(ScanActivity.class);
    integrator.setOrientationLocked(false);

    // limit scanning to only one-dimensional barcodes
    integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);

    // set the prompt message
    integrator.setPrompt(getString(R.string.scanner_prompt));

    // launch the scanner
    integrator.initiateScan();
  }
Exemplo n.º 5
0
 /**
  * Initiates a scan, only for a certain set of barcode types, given as strings corresponding to
  * their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants like
  * {@link #PRODUCT_CODE_TYPES} for example.
  *
  * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for
  */
 public final void initiateScan(Collection<String> desiredBarcodeFormats) {
   setDesiredBarcodeFormats(desiredBarcodeFormats);
   initiateScan();
 }