com.google.zxing.integration.android.IntentIntegrator Java Examples

The following examples show how to use com.google.zxing.integration.android.IntentIntegrator. 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: ShareContactActivity.java    From Travel-Mate with MIT License 8 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (result != null) {
        //if QRcode has nothing in it
        if (result.getContents() != null) {
            //if QRCode contains data
            //retrieve results
            String resultContents = result.getContents();
            String[] values = resultContents.split(":");
            String userName = values[0];
            String userEmail = values[1];
            addContact(userName, userEmail);
        }
    }
}
 
Example #2
Source File: FragmentPaymentBillViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
public void onClickBarCode(View v) {

        try {
            HelperPermission.getCameraPermission(G.currentActivity, new OnGetPermission() {
                @Override
                public void Allow() throws IOException, IllegalStateException {
                    IntentIntegrator integrator = IntentIntegrator.forSupportFragment(fragmentPaymentBill);
                    integrator.setDesiredBarcodeFormats(IntentIntegrator.CODE_128);
                    integrator.setRequestCode(requestCodeBarcode);
                    integrator.setBeepEnabled(false);
                    integrator.setPrompt("");
                    integrator.initiateScan();
                }

                @Override
                public void deny() {
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
 
Example #3
Source File: ConversationListActivity.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  switch (requestCode) {
    case IntentIntegrator.REQUEST_CODE:
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
      QrCodeHandler qrCodeHandler = new QrCodeHandler(this);
      qrCodeHandler.onScanPerformed(scanResult);
      break;
    case REQUEST_RELAY:
      if (resultCode == RESULT_OK) {
        handleResetRelaying();
        setResult(RESULT_OK);
        finish();
      }
      break;
    default:
      break;
  }
}
 
Example #4
Source File: SettingsActivity.java    From ShoppingList with Apache License 2.0 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null) {
        Gson gson = new Gson();
        try {
            BackendSettings backendSettings = gson.fromJson(scanResult.getContents().toString(), BackendSettings.class);
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("host", backendSettings.getHost());
            editor.putString("authkey", backendSettings.getAuth());
            editor.putBoolean("useSSL", backendSettings.getSsl());
            editor.commit();
            Toast.makeText(getApplicationContext(),"Success!", Toast.LENGTH_SHORT).show();
            refreshValues();
        } catch (Exception e){
            Toast.makeText(getApplicationContext(),"QR Code: Wrong data!", Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example #5
Source File: KeyScanningActivity.java    From Silence with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
  IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

  if ((scanResult != null) && (scanResult.getContents() != null)) {
    String data = scanResult.getContents();

    if (data.equals(Base64.encodeBytes(getIdentityKeyToCompare().serialize()))) {
      Dialogs.showInfoDialog(this, getVerifiedTitle(), getVerifiedMessage());
    } else {
      Dialogs.showAlertDialog(this, getNotVerifiedTitle(), getNotVerifiedMessage());
    }
  } else {
    Toast.makeText(this, R.string.KeyScanningActivity_no_scanned_key_found_exclamation,
                   Toast.LENGTH_LONG).show();
  }
}
 
Example #6
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 #7
Source File: MainActivity.java    From a-sync-browser with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Receives value of scanned QR code and sets it as device ID.
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    if (scanResult != null) {
        String deviceId = scanResult.getContents();
        if (!isBlank(deviceId)) {
            Log.i("Main", "qrcode text = " + deviceId);
            importDeviceId(deviceId);
            return;
        }
    }

    if (resultCode == Activity.RESULT_OK) {
        Uri fileUri = intent.getData();
        doUpload(indexBrowser.getFolder(), indexBrowser.getCurrentPath(), Arrays.asList(fileUri));
    }
}
 
Example #8
Source File: SignFragment.java    From tron-wallet-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if(result != null) {
        if(result.getContents() != null) {
            try {
                Protocol.Transaction transaction = Protocol.Transaction.parseFrom(Hex.decode(result.getContents()));
                if(getContext() != null) {
                    ConfirmTransactionActivity.start(getContext(), transaction);
                }
            } catch (InvalidProtocolBufferException | DecoderException ignored) { }
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example #9
Source File: SignFragment.java    From tron-wallet-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mQR_Button = view.findViewById(R.id.Sign_qr_imageButton);

    mQR_Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            IntentIntegrator integrator = IntentIntegrator.forSupportFragment(SignFragment.this);
            integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
            integrator.setPrompt(getString(R.string.scan_transaction_qr_code));
            integrator.setCameraId(0);
            integrator.setBeepEnabled(false);
            integrator.setOrientationLocked(true);
            integrator.setCaptureActivity(CaptureActivityPortrait.class);
            integrator.initiateScan();
        }
    });
}
 
Example #10
Source File: ThinJamActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    val scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);

    if (scanResult == null || scanResult.getContents() == null) {
        return;
    }
    if (scanResult.getFormatName().equals("QR_CODE")) {

        try {
            BlueJay.processQRCode(scanResult.getRawBytes());
        } catch (Exception e) {
            // meh
        }

    }
}
 
Example #11
Source File: AndroidBarcode.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public void scan() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (ContextCompat.checkSelfPermission(activity.getApplicationContext(),
                    Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {

                ActivityCompat.requestPermissions(activity,
                        new String[]{Manifest.permission.CAMERA},
                        MY_PERMISSIONS_REQUEST_CAMERA);
            } else {
                new IntentIntegrator(activity).initiateScan();
            }
        } else {
            new IntentIntegrator(activity).initiateScan();
        }
    }
 
Example #12
Source File: MainActivity.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {

        if (requestCode == IntentIntegrator.REQUEST_CODE) {
            // 扫描二维码回传值
            IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
            String ewmString = result.getContents();

            Intent mintent = new Intent(MainActivity.this, QuickWebLoader.class);
            QuickBean bean = new QuickBean(ewmString);
            mintent.putExtra("bean", bean);
            startActivity(mintent);
        }
    }
}
 
Example #13
Source File: ImportWalletActivity.java    From tron-wallet-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(IntentIntegrator.REQUEST_CODE, resultCode, data);
    if(result != null) {
        if(result.getContents() != null) {
            switch (requestCode) {
                case ADDRESS_REQUEST_CODE:
                    mPublicAddress_EditText.setText(result.getContents());
                    break;
                case PRIV_KEY_REQUEST_CODE:
                    mPrivateKey_EditText.setText(result.getContents());
                    break;

                    default:
                        super.onActivityResult(requestCode, resultCode, data);
            }
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example #14
Source File: ActivityMain.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
        case requestCodePaymentCharge:
        case requestCodePaymentBill:
            getPaymentResultCode(resultCode, data);
            break;
        case requestCodeQrCode:
            IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data);
            if (result.getContents() != null) {
                new RequestUserVerifyNewDevice().verifyNewDevice(result.getContents());
            }
            break;
    }
}
 
Example #15
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 #16
Source File: MainActivity.java    From PLDroidMediaStreaming with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK) {
        return;
    }
    if (requestCode ==  IntentIntegrator.REQUEST_CODE) {
        IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if(result != null) {
            if(result.getContents() == null) {
                Toast.makeText(this, "扫码取消!", Toast.LENGTH_SHORT).show();
            } else {
                mInputTextTV.setText(result.getContents());
            }
        }
    }
}
 
Example #17
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 #18
Source File: AndroidBarcode.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case MY_PERMISSIONS_REQUEST_CAMERA: {
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                new IntentIntegrator(activity).initiateScan();
            } else {
                toast("Without camera permission we cannot scan a barcode");
            }
            return;
        }

    }
}
 
Example #19
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 #20
Source File: AndroidBarcode.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void scan() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (ContextCompat.checkSelfPermission(activity.getApplicationContext(),
                    Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {

                ActivityCompat.requestPermissions(activity,
                        new String[]{Manifest.permission.CAMERA},
                        MY_PERMISSIONS_REQUEST_CAMERA);
            } else {
                new IntentIntegrator(activity).initiateScan();
            }
        } else {
            new IntentIntegrator(activity).initiateScan();
        }
    }
 
Example #21
Source File: AndroidBarcode.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case MY_PERMISSIONS_REQUEST_CAMERA: {
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                new IntentIntegrator(activity).initiateScan();
            } else {
                toast("Without camera permission we cannot scan a barcode");
            }
            return;
        }

    }
}
 
Example #22
Source File: KeyScanningActivity.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
private IntentIntegrator getIntentIntegrator() {
  IntentIntegrator intentIntegrator = new IntentIntegrator(this);
  intentIntegrator.setButtonYesByID(R.string.yes);
  intentIntegrator.setButtonNoByID(R.string.no);
  intentIntegrator.setTitleByID(R.string.KeyScanningActivity_install_barcode_Scanner);
  intentIntegrator.setMessageByID(R.string.KeyScanningActivity_this_application_requires_barcode_scanner_would_you_like_to_install_it);
  return intentIntegrator;
}
 
Example #23
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 #24
Source File: MainActivity.java    From moserp with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (result != null) {
        if (result.getContents() == null) {
            Log.d("MainActivity", "Cancelled scan");
            Toast.makeText(this.getApplicationContext(), R.string.toast_scan_cancelled, Toast.LENGTH_LONG).show();
        } else {
            Log.d("MainActivity", "Scanned: " + result.getContents());
            startActivity(ProductListActivity.buildIntent(getApplicationContext(), result.getContents()));
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example #25
Source File: MainActivity.java    From lector_Android with MIT License 5 votes vote down vote up
public void scanBarcode(View view){
    new IntentIntegrator(this)
            .setOrientationLocked(false)
            .setCaptureActivity(ScanerCedulasCR.class)
            .setDesiredBarcodeFormats(TYPES)
            .initiateScan();
}
 
Example #26
Source File: FormRecordListActivity.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private static void callBarcodeScanIntent(Activity act) {
    Intent intent = new IntentIntegrator(act).createScanIntent();
    try {
        act.startActivityForResult(intent, BARCODE_FETCH);
    } catch (ActivityNotFoundException anfe) {
        Toast.makeText(act,
                "No barcode reader available! You can install one " +
                        "from the android market.",
                Toast.LENGTH_LONG).show();
    }
}
 
Example #27
Source File: SettingsFragment.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate called");

    super.onCreate(savedInstanceState);
    final SettingsFragment that = this;

    /* set preferences */
    addPreferencesFromResource(R.xml.preferences);

    // iterate through all preferences and update to saved value
    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
        initSummary(getPreferenceScreen().getPreference(i));
    }

    setMinBatPollIntervall((ListPreference) findPreference("pollInterval"), (ListPreference) findPreference("lowBatPollInterval"));

    Preference button = findPreference("scanButton");
    button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            IntentIntegrator integrator = new IntentIntegrator(that);
            integrator.initiateScan();

            return true;
        }
    });
}
 
Example #28
Source File: BluetoothScan.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (scanResult == null || scanResult.getContents() == null) {
        return;
    }
    if (scanResult.getFormatName().equals("CODE_128")) {
        Log.d(TAG, "Setting serial number to: " + scanResult.getContents());
        prefs.edit().putString("share_key", scanResult.getContents()).apply();
        returnToHome();
    }
}
 
Example #29
Source File: BluetoothScan.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (scanResult == null || scanResult.getContents() == null) {
        return;
    }
    if (scanResult.getFormatName().equals("CODE_128")) {
        Log.d(TAG, "Setting serial number to: " + scanResult.getContents());
        prefs.edit().putString("share_key", scanResult.getContents()).apply();
        returnToHome();
    }
}
 
Example #30
Source File: AddProductDialogFragment.java    From pos with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
	IntentResult scanningResult = IntentIntegrator.parseActivityResult(
			requestCode, resultCode, intent);

	if (scanningResult != null) {
		String scanContent = scanningResult.getContents();
		barcodeBox.setText(scanContent);
	} else {
		Toast.makeText(getActivity().getBaseContext(),
				res.getString(R.string.fail),
				Toast.LENGTH_SHORT).show();
	}
}