Java Code Examples for com.google.zxing.integration.android.IntentIntegrator#setDesiredBarcodeFormats()

The following examples show how to use com.google.zxing.integration.android.IntentIntegrator#setDesiredBarcodeFormats() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WXDebugActivity.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    if (textBack.equals(v)) {
        finish();
    } else if (textScan.equals(v)) {
        IntentIntegrator integrator = new IntentIntegrator(this);
        integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
        integrator.setPrompt("Scan a barcode");
        //integrator.setCameraId(0);  // Use a specific camera of the device
        integrator.setBeepEnabled(true);
        integrator.setOrientationLocked(false);
        integrator.setBarcodeImageEnabled(true);
        integrator.setPrompt("请将条码置于取景框内扫描");
        integrator.initiateScan();
    } else if (btnSave.equals(v)) {
        save();
    } else if (btnReset.equals(v)) {
        save();
        AppExitUtil.restart(this);
    } else if (btnOpen.equals(v)) {
        String page = editOpen.getText().toString().trim();
        UWXJumpUtil.openPage(this, page);
    }
}
 
Example 2
Source File: WXPageActivity.java    From yanxuan-weex-demo with MIT License 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.action_refresh:
      createWeexInstance();
      renderPage();
      break;
    case R.id.action_scan:
      IntentIntegrator integrator = new IntentIntegrator(this);
      integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
      integrator.setPrompt("Scan a barcode");
      //integrator.setCameraId(0);  // Use a specific camera of the device
      integrator.setBeepEnabled(true);
      integrator.setOrientationLocked(false);
      integrator.setBarcodeImageEnabled(true);
      integrator.setPrompt(getString(R.string.capture_qrcode_prompt));
      integrator.initiateScan();
      break;
    case android.R.id.home:
      finish();
    default:
      break;
  }

  return super.onOptionsItemSelected(item);
}
 
Example 3
Source File: ThirdPartyScannerActivity.java    From SecScanQR with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method handles the communication to the ZXING API -> Apache License 2.0
 * For more information please check out the link below.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */
public void zxingScan(){
    IntentIntegrator integrator = new IntentIntegrator(activity);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
    integrator.setPrompt((String) getResources().getText(R.string.xzing_label));

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String camera_setting = prefs.getString("pref_camera", "");
    if(camera_setting.equals("1")){
        integrator.setCameraId(1);
    } else {
        integrator.setCameraId(0);
    }

    integrator.setOrientationLocked(false);
    integrator.setBeepEnabled(false);
    integrator.setBarcodeImageEnabled(false);
    try {
        integrator.initiateScan();
    } catch (ArithmeticException e){

    }
}
 
Example 4
Source File: ScannerActivity.java    From SecScanQR with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method handles the communication to the ZXING API -> Apache License 2.0
 * For more information please check out the link below.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */
public void zxingScan(){
    IntentIntegrator integrator = new IntentIntegrator(activity);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
    integrator.setPrompt((String) getResources().getText(R.string.xzing_label));

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String camera_setting = prefs.getString("pref_camera", "");
    if(camera_setting.equals("1")){
        integrator.setCameraId(1);
    } else {
        integrator.setCameraId(0);
    }

    integrator.setOrientationLocked(false);
    integrator.setBeepEnabled(false);
    integrator.setBarcodeImageEnabled(false);
    try {
        integrator.initiateScan();
    } catch (ArithmeticException e){

    }
}
 
Example 5
Source File: IndexActivity.java    From WeexOne with MIT License 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_refresh:
            createWeexInstance();
            renderPage();
            break;
        case R.id.action_scan:
            IntentIntegrator integrator = new IntentIntegrator(this);
            integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
            integrator.setPrompt("Scan a barcode");
            //integrator.setCameraId(0);  // Use a specific camera of the device
            integrator.setBeepEnabled(true);
            integrator.setOrientationLocked(false);
            integrator.setBarcodeImageEnabled(true);
            integrator.initiateScan();
            //scanQrCode();
            break;
        default:
            break;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 6
Source File: MainActivity.java    From secure-quick-reliable-login with MIT License 5 votes vote down vote up
private void initiateScan() {
    final IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
    integrator.setCameraId(0);
    integrator.setBeepEnabled(false);
    integrator.setOrientationLocked(false);
    integrator.setBarcodeImageEnabled(false);
    integrator.setPrompt(this.getString(R.string.scan_site_code));
    integrator.initiateScan();
}
 
Example 7
Source File: MainActivity.java    From PLDroidMediaStreaming with Apache License 2.0 5 votes vote down vote up
public void scanQRCode(View v) {
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
    integrator.setOrientationLocked(true);
    integrator.setCameraId(0);
    integrator.setBeepEnabled(true);
    integrator.initiateScan();
}
 
Example 8
Source File: ImportActivity.java    From secure-quick-reliable-login with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_import);

    rootView = findViewById(R.id.importActivityView);
    txtImportMessage = findViewById(R.id.txtImportMessage);
    btnImportIdentityDo = findViewById(R.id.btnImportIdentityDo);
    btnForgotPassword = findViewById(R.id.btnForgotPassword);
    txtPassword = findViewById(R.id.txtPassword);

    txtPassword.setEnabled(true);
    btnImportIdentityDo.setEnabled(true);
    btnForgotPassword.setEnabled(true);

    setupProgressPopupWindow(getLayoutInflater());
    setupErrorPopupWindow(getLayoutInflater());

    txtPassword.setOnEditorActionListener((v, actionId, event) -> {
        switch (actionId) {
            case EditorInfo.IME_ACTION_DONE:
                doImport();
                return true;
            default:
                return false;
        }
    });

    btnForgotPassword.setOnClickListener(
            v -> {
                ImportActivity.this.finish();
                Intent resetPasswordIntent = new Intent(this, ResetPasswordActivity.class);
                resetPasswordIntent.putExtra(SQRLStorage.NEW_IDENTITY, true);
                startActivity(resetPasswordIntent);
            }
    );

    btnImportIdentityDo.setOnClickListener(v -> doImport());

    boolean testing = getIntent().getBooleanExtra("RUNNING_TEST", false);
    if(testing) {
        return;
    }

    Intent intent = getIntent();
    if (intent.getAction() != null && intent.getType() != null &&
            intent.getAction().equals(Intent.ACTION_VIEW) &&
            (intent.getType().startsWith("text/") || intent.getType().startsWith("application/"))) {
        handleFileIntent(intent.getData());
        return;
    }

    String importMethod = intent.getStringExtra(EXTRA_IMPORT_METHOD);
    if (importMethod == null) return;

    if (importMethod.equals(IMPORT_METHOD_FILE)) {
        chooseFile();
        return;
    }

    if (importMethod.equals(IMPORT_METHOD_QR_CODE)) {
        final IntentIntegrator integrator = new IntentIntegrator(this);
        integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
        integrator.setCameraId(0);
        integrator.setBeepEnabled(false);
        integrator.setOrientationLocked(false);
        integrator.setBarcodeImageEnabled(false);

        integrator.setPrompt(this.getString(R.string.scan_identity));
        integrator.initiateScan();
    }

    if (importMethod.equals(IMPORT_METHOD_FORWARDED_QR_CODE)) {
        byte[] identityData = intent.getByteArrayExtra(EXTRA_FORWARDED_QR_CODE);
        if (identityData == null) return;
        try {
            readIdentityData(identityData);
        } catch (Exception e) {
            showErrorMessage(e.getMessage());
            Log.e(TAG, e.getMessage(), e);
        }
    }
}