@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.webModeration:
       IntentIntegrator integrator = new IntentIntegrator(this);
       integrator.setCaptureActivity(CaptureActivityAnyOrientation.class);
       integrator.setOrientationLocked(false);
       integrator.initiateScan();
   }
   return super.onOptionsItemSelected(item);
 }
예제 #2
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();
  }
예제 #3
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();
  }