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

The following examples show how to use com.google.zxing.integration.android.IntentIntegrator#initiateScan() . 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: DeploymentsActivity.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void scanFieldPaper(View view) {
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setCaptureActivity(ZXingActivity.class);
    integrator.setOrientationLocked(false);
    integrator.setPrompt("Place a field paper QR code inside the viewfinder to scan.");
    integrator.setBeepEnabled(true);
    integrator.initiateScan();
}
 
Example 8
Source File: DeviceActivity.java    From syncthing-android with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (v.equals(mCompressionContainer)) {
        showCompressionDialog();
    } else if (v.equals(mQrButton)){
        IntentIntegrator integrator = new IntentIntegrator(DeviceActivity.this);
        integrator.initiateScan();
    } else if (v.equals(mIdContainer)) {
        Util.copyDeviceId(this, mDevice.deviceID);
    }
}
 
Example 9
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 10
Source File: TutorialFragment.java    From Sparkplug with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    if (view.getId()==R.id.scan_button) {
        IntentIntegrator scanIntegrator = new IntentIntegrator(((MainActivity) getActivity()));
        scanIntegrator.initiateScan();
    }
}
 
Example 11
Source File: ShareContactActivity.java    From Travel-Mate with MIT License 5 votes vote down vote up
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.scan:
            IntentIntegrator qrScan = new IntentIntegrator(this);
            qrScan.initiateScan();
            break;
    }
}
 
Example 12
Source File: UtilApi.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 打开二维码
 * <p>
 * 参数:
 * videoUrl:视频地址
 */
public static void scan(IQuickFragment webLoader, WebView wv, JSONObject param, Callback callback) {
    Object fragment = webLoader.getPageControl().getFragment();
    IntentIntegrator integrator = null;
    if (fragment instanceof Fragment) {
        integrator = IntentIntegrator.forFragment((Fragment) fragment);
    } else if (fragment instanceof android.support.v4.app.Fragment) {
        integrator = IntentIntegrator.forSupportFragment((android.support.v4.app.Fragment) fragment);
    }
    if (integrator != null) {
        integrator.setCaptureActivity(ScanCaptureActivity.class);
        integrator.initiateScan();
        webLoader.getWebloaderControl().addPort(AutoCallbackDefined.OnScanCode, callback.getPort());
    }
}
 
Example 13
Source File: BarCodeCodecFragment.java    From text_converter with GNU General Public License v3.0 5 votes vote down vote up
private void decodeUseCamera() {
    IntentIntegrator integrator = IntentIntegrator.forSupportFragment(this);
    integrator.setBeepEnabled(true);
    integrator.setBarcodeImageEnabled(true);
    integrator.setOrientationLocked(true);
    integrator.initiateScan();
}
 
Example 14
Source File: ScanActivity.java    From HomeApplianceMall with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    // 创建IntentIntegrator对象
    IntentIntegrator intentIntegrator = new IntentIntegrator(ScanActivity.this);
    intentIntegrator.setPrompt("开始扫描");
    intentIntegrator.setTimeout(5*1000);
    intentIntegrator.setBeepEnabled(false);
    // 开始扫描
    intentIntegrator.initiateScan();
}
 
Example 15
Source File: MainActivity.java    From a-sync-browser with Mozilla Public License 2.0 4 votes vote down vote up
public void openQrcode() {
    IntentIntegrator integrator = new IntentIntegrator(MainActivity.this);
    integrator.initiateScan();
}
 
Example 16
Source File: KeyScanningActivity.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
protected void initiateScan() {
  IntentIntegrator intentIntegrator = getIntentIntegrator();
  intentIntegrator.initiateScan();
}
 
Example 17
Source File: SwapWorkflowActivity.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Attempts to open a QR code scanner, in the hope a user will then scan the QR code of another
 * device configured to swapp apps with us. Delegates to the zxing library to do so.
 */
public void initiateQrScan() {
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.initiateScan();
}
 
Example 18
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);
        }
    }
}