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

The following examples show how to use com.google.zxing.integration.android.IntentIntegrator#setCameraId() . 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: 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 2
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 3
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 4
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 5
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);
        }
    }
}