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
  }
  @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();
  }
Beispiel #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();
  }
 public void startQRScanner(String message) {
   qrScanStartTime = System.currentTimeMillis();
   IntentIntegrator integrator = new IntentIntegrator(this);
   integrator.setPrompt(message);
   integrator.initiateScan();
 }