Java Code Examples for com.google.zxing.integration.android.IntentIntegrator#parseActivityResult()
The following examples show how to use
com.google.zxing.integration.android.IntentIntegrator#parseActivityResult() .
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 |
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: MainActivity.java From a-sync-browser with Mozilla Public License 2.0 | 6 votes |
/** * 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 3
Source File: MainActivity.java From quickhybrid-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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 4
Source File: SignFragment.java From tron-wallet-android with Apache License 2.0 | 6 votes |
@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 5
Source File: ConversationListActivity.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
@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 6
Source File: BluetoothScan.java From xDrip with GNU General Public License v3.0 | 5 votes |
@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 7
Source File: InventoryFragment.java From pos with Eclipse Public License 1.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanningResult = IntentIntegrator.parseActivityResult( requestCode, resultCode, intent); if (scanningResult != null) { String scanContent = scanningResult.getContents(); searchBox.setText(scanContent); } else { Toast.makeText(getActivity().getBaseContext(), res.getString(R.string.fail), Toast.LENGTH_SHORT).show(); } }
Example 8
Source File: AddressBookActivity.java From bitseal with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { ((AddressBookRecordAdapter)mAddressBookListView.getAdapter()).notifyDataSetChanged(); // Get the result of the QR code scan IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (result != null) { String contents = result.getContents(); if (contents != null) { contents = contents.trim(); // Remove leading or trailing spaces Log.i(TAG, "Found QRcode with the following contents: " + contents); if (contents.substring(0, 3).equals(BITMESSAGE_ADDRESS_PREFIX)) { openNewEntryDialog(contents); } else { Toast.makeText(getApplicationContext(), R.string.addressBook_toast_qr_address_invalid, Toast.LENGTH_LONG).show(); openNewEntryDialog(""); } } else { Log.i(TAG, "No QRcode found"); openNewEntryDialog(""); } } }
Example 9
Source File: WXPageActivity.java From yanxuan-weex-demo with MIT License | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if (result != null) { if (result.getContents() == null) { Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show(); } else { handleDecodeInternally(result.getContents()); } } super.onActivityResult(requestCode, resultCode, data); }
Example 10
Source File: WelcomeActivity.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode==IntentIntegrator.REQUEST_CODE) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if (scanResult == null || scanResult.getFormatName() == null) { return; // aborted } String qrRaw = scanResult.getContents(); DcLot qrParsed = dcContext.checkQr(qrRaw); switch (qrParsed.getState()) { case DcContext.DC_QR_ACCOUNT: String domain = qrParsed.getText1(); new AlertDialog.Builder(this) .setMessage(getString(R.string.qraccount_ask_create_and_login, domain)) .setPositiveButton(R.string.ok, (dialog, which) -> startQrAccountCreation(qrRaw)) .setNegativeButton(R.string.cancel, null) .setCancelable(false) .show(); break; default: new AlertDialog.Builder(this) .setMessage(R.string.qraccount_qr_code_cannot_be_used) .setPositiveButton(R.string.ok, null) .show(); break; } } }
Example 11
Source File: HomeActivity.java From CrazyDaily with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { IntentResult result = IntentIntegrator.parseActivityResult(resultCode, data); String scanResult = result.getContents(); if (scanResult != null) { BrowserActivity.start(this, scanResult); } }
Example 12
Source File: MainActivity.java From CameraViewer with Apache License 2.0 | 5 votes |
public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult != null) { String jsonText = scanResult.getContents(); if (TextUtils.isEmpty(jsonText)) return; try { JSONObject jsonObject = new JSONObject(jsonText); String IP = jsonObject.getString("IP"); int Port = jsonObject.getInt("PORT"); String Password = jsonObject.getString("PASSWORD"); int camNumber = jsonObject.getInt("CAMNUMBER"); String deviceId = jsonObject.getString("DEVICEID"); MyCameraInfo myCamera = new MyCameraInfo(); myCamera.setIP(IP); myCamera.setPort(Port); myCamera.setPassword(Password); myCamera.setCamNumber(camNumber); myCamera.setDeviceId(deviceId); //保存到本地数据库 if (!MyCameraDB.getInstance(MainActivity.this).saveMyCamera(myCamera)) { Toast.makeText(MainActivity.this, "添加远程摄像头失败,目标已存在", Toast.LENGTH_SHORT).show(); } else { mCameraList.add(myCamera); ((MyAdapter) mLVCamera.getAdapter()).notifyDataSetChanged(); Toast.makeText(MainActivity.this, "添加成功", Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { e.printStackTrace(); Toast.makeText(MainActivity.this, "添加失败", Toast.LENGTH_SHORT).show(); } } }
Example 13
Source File: AddProductDialogFragment.java From pos with Eclipse Public License 1.0 | 5 votes |
@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(); } }
Example 14
Source File: AddFriendQRActivity.java From NaviBee with GNU General Public License v3.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if(result != null) { addFriend(result.getContents()); } else { super.onActivityResult(requestCode, resultCode, data); } }
Example 15
Source File: MainActivity.java From Sparkplug with Eclipse Public License 1.0 | 5 votes |
public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); // Log.d(TAG, "Got something? " + resultCode + " :: " + intent.toString()); if (scanningResult != null) { Log.d(TAG, "Got something? " + scanningResult.toString()); } else{ Log.d(TAG, "Didn't get anything?"); } }
Example 16
Source File: SubscriptionsActivity.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void onActivityResult(int requestCode, int resultCode, Intent intent) { try { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult == null) return; parseTokenOrUri(scanResult.getContents().trim()); } catch (PushfishException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } catch (NullPointerException ignore) { } }
Example 17
Source File: DeviceActivity.java From syncthing-android with Mozilla Public License 2.0 | 5 votes |
/** * 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) { mDevice.deviceID = scanResult.getContents(); mIdView.setText(mDevice.deviceID); } }
Example 18
Source File: MainActivity.java From andOTP with MIT License | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if(result != null) { if(result.getContents() != null) { addQRCode(result.getContents()); } } else if (requestCode == Constants.INTENT_MAIN_BACKUP && resultCode == RESULT_OK) { if (intent.getBooleanExtra("reload", false)) { adapter.loadEntries(); refreshTags(); } } else if (requestCode == Constants.INTENT_MAIN_SETTINGS && resultCode == RESULT_OK) { boolean encryptionChanged = intent.getBooleanExtra(Constants.EXTRA_SETTINGS_ENCRYPTION_CHANGED, false); byte[] newKey = intent.getByteArrayExtra(Constants.EXTRA_SETTINGS_ENCRYPTION_KEY); if (encryptionChanged) updateEncryption(newKey); if (recreateActivity) { cacheEncKey = true; recreate(); } } else if (requestCode == Constants.INTENT_MAIN_AUTHENTICATE) { if (resultCode != RESULT_OK) { Toast.makeText(getBaseContext(), R.string.toast_auth_failed_fatal, Toast.LENGTH_LONG).show(); finishAndRemoveTask(); } else { requireAuthentication = false; byte[] authKey = null; if (intent != null) authKey = intent.getByteArrayExtra(Constants.EXTRA_AUTH_PASSWORD_KEY); updateEncryption(authKey); } } else if (requestCode == Constants.INTENT_MAIN_QR_OPEN_IMAGE && resultCode == RESULT_OK) { if (intent != null) { addQRCode(ScanQRCodeFromFile.scanQRImage(this, intent.getData())); } } }
Example 19
Source File: MainActivity.java From secure-quick-reliable-login with MIT License | 4 votes |
@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(TAG, "Cancelled scan"); Snackbar.make(rootView, R.string.scan_cancel, Snackbar.LENGTH_LONG).show(); if(!mDbHelper.hasIdentities()) { startActivity(new Intent(this, WizardPage1Activity.class)); } } else { byte[] qrCodeData = null; try { qrCodeData = Utils.readSQRLQRCode(data); } catch (FormatException fe) { Snackbar.make(rootView, R.string.scan_incorrect, Snackbar.LENGTH_LONG).show(); return; } if (qrCodeData == null) { Snackbar.make(rootView, R.string.scan_incorrect, Snackbar.LENGTH_LONG).show(); return; } // If an identity qr-code was scanned instead of a login qr code, // simply forward it to the import activity and bail out if (qrCodeData.length > 8 && new String(Arrays.copyOfRange(qrCodeData, 0, 8)) .startsWith(SQRLStorage.STORAGE_HEADER)) { Intent importIntent = new Intent(this, ImportActivity.class); importIntent.putExtra(ImportActivity.EXTRA_IMPORT_METHOD, ImportActivity.IMPORT_METHOD_FORWARDED_QR_CODE); importIntent.putExtra(ImportActivity.EXTRA_FORWARDED_QR_CODE, qrCodeData); startActivity(importIntent); return; } final String serverData = new String(qrCodeData); Uri serverUri = Uri.parse(serverData); if (!Utils.isValidSqrlUri(serverUri)) { Snackbar.make(rootView, R.string.scan_incorrect, Snackbar.LENGTH_LONG).show(); return; } Intent urlLoginIntent = new Intent(Intent.ACTION_VIEW); urlLoginIntent.setData(serverUri); urlLoginIntent.putExtra(LoginActivity.EXTRA_USE_CPS, false); if (ACTION_QUICK_SCAN.equals(getIntent().getAction())) urlLoginIntent.putExtra(LoginActivity.EXTRA_QUICK_SCAN, true); startActivity(urlLoginIntent); } } }
Example 20
Source File: ScannerActivity.java From SecScanQR with GNU General Public License v3.0 | 4 votes |
/** * This method handles the results of the scan */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data){ IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if(result != null){ if(result.getContents()==null){ Toast.makeText(this, getResources().getText(R.string.error_canceled_scan), Toast.LENGTH_LONG).show(); } else { qrcodeFormat = result.getFormatName(); qrcode = result.getContents(); if(!qrcode.equals("")){ codeImage.setVisibility(View.VISIBLE); showQrImage(); mTvFormat.setVisibility(View.VISIBLE); mLabelInformation.setVisibility(View.VISIBLE); mLabelFormat.setVisibility(View.VISIBLE); mTvFormat.setText(qrcodeFormat); mTvInformation.setText(qrcode); action_navigation.setVisibility(View.VISIBLE); if(qrcode.contains("BEGIN:VCARD") & qrcode.contains("END:VCARD")){ action_navigation_web_button.setVisibility(View.GONE); action_navigation_contact_button.setVisibility(View.VISIBLE); } else { action_navigation_contact_button.setVisibility(View.GONE); action_navigation_web_button.setVisibility(View.VISIBLE); } //Check if history is activated SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String history_setting = prefs.getString("pref_history", ""); if(history_setting.equals("false")){ //Don't save QR-Code in history } else { addToDatabase(mTvInformation.getText().toString(), mTvFormat.getText().toString()); } //Automatic Clipboard if activated Boolean auto_scan = prefs.getBoolean("pref_start_auto_clipboard", false); if(auto_scan == true){ copyToClipboard(mTvInformation, qrcode, activity); } } } } else { super.onActivityResult(requestCode, resultCode, data); } }