@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); } } }
@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); }
@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); } }
/** * 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 { qrcode = result.getContents(); if(!qrcode.equals("")){ mTextMessage.setText(qrcode); action_navigation.setVisibility(View.VISIBLE); addToDatabase(mTextMessage.getText().toString()); //Automatic Clipboard if activated SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String auto_scan = prefs.getString("pref_auto_clipboard", ""); if(auto_scan.equals("true")){ copyToClipboard(mTextMessage, qrcode, activity); } } } } else { super.onActivityResult(requestCode, resultCode, data); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { IntentResult result = IntentIntegrator.parseActivityResult( requestCode, resultCode, data); if (result != null) { if ( result.getContents() == null) { this.scan = null; long newInstance = Calendar.getInstance().getTimeInMillis(); if ( newInstance - this.startScannerTime < 1000 * this.timeOutSecond ) { this.onCanceled(); } else { this.onTimeOut(); } } else { this.scan = new Scan( result.getContents() ); ScanDao scanDao = new ScanDao( this ); scanDao.register( this.scan); this.onScanReaderResult( this.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) { QRReadTask task = new QRReadTask(); task.execute(result.getContents()); if (EssensbonUtils.isAutoFadeEnabled()) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { integrator.initiateScan(); } }, EssensbonUtils.getFadeTime()*1000); } } } else { super.onActivityResult(requestCode, resultCode, data); } }
protected boolean handleIntent(Intent intent) { if (intent != null && intent.getAction().equals(ACTION_VERIFY_CONTACT)) { this.mAccount = extractAccount(intent); if (this.mAccount == null) { return false; } try { this.mConversation = this.xmppConnectionService.find(this.mAccount,Jid.fromString(intent.getExtras().getString("contact"))); if (this.mConversation == null) { return false; } } catch (final InvalidJidException ignored) { return false; } this.mode = intent.getIntExtra("mode", MODE_MANUAL_VERIFICATION); if (this.mode == MODE_SCAN_FINGERPRINT) { new IntentIntegrator(this).initiateScan(); return false; } return true; } else { return false; } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if ((requestCode & 0xFFFF) == IntentIntegrator.REQUEST_CODE) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult != null && scanResult.getFormatName() != null) { String data = scanResult.getContents(); XmppUri uri = new XmppUri(data); if (xmppConnectionServiceBound) { verifyWithUri(uri); finish(); } else { this.mPendingUri = uri; } } else { finish(); } } super.onActivityResult(requestCode, requestCode, intent); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_create_contact: showCreateContactDialog(null, null); return true; case R.id.action_join_conference: showJoinConferenceDialog(null); return true; case R.id.action_create_conference: showCreateConferenceDialog(); return true; case R.id.action_scan_qr_code: new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC","QR_CODE")); return true; case R.id.action_hide_offline: mHideOfflineContacts = !item.isChecked(); getPreferences().edit().putBoolean("hide_offline", mHideOfflineContacts).commit(); if (mSearchEditText != null) { filter(mSearchEditText.getText().toString()); } invalidateOptionsMenu(); } return super.onOptionsItemSelected(item); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.fragment_send_dialog_send: sendCoins(); break; case R.id.fragment_send_dialog_cancel: getDialog().cancel(); break; case R.id.fragment_send_dialog_qr_scan: IntentIntegrator.forFragment(SendDialogFragment.this).initiateScan(); break; case R.id.fragment_send_dialog_address: openAddressList(); break; } }
@Override public void onCreate(Bundle savedInstanceState) { 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; } }); }
@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; } } }
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(); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_create_contact: showCreateContactDialog(null,null); return true; case R.id.action_join_conference: showJoinConferenceDialog(null); return true; case R.id.action_scan_qr_code: new IntentIntegrator(this).initiateScan(); return true; case R.id.action_hide_offline: mHideOfflineContacts = !item.isChecked(); getPreferences().edit().putBoolean("hide_offline", mHideOfflineContacts).commit(); if (mSearchEditText != null) { filter(mSearchEditText.getText().toString()); } invalidateOptionsMenu(); return true; } return super.onOptionsItemSelected(item); }
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if ((requestCode & 0xFFFF) == IntentIntegrator.REQUEST_CODE) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult != null && scanResult.getFormatName() != null) { String data = scanResult.getContents(); Invite invite = new Invite(data); if (xmppConnectionServiceBound) { invite.invite(); } else if (invite.getJid() != null) { this.mPendingInvite = invite; } else { this.mPendingInvite = null; } } } super.onActivityResult(requestCode, requestCode, intent); }
/** * 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)); } }
@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(); } }
@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); }
@OnClick(R.id.barcode_image) void setupBarcodes() { // IntentIntegrator integrator = new IntentIntegrator(getActivity()); // integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES); // integrator.setPrompt("Scan a barcode"); // integrator.setCameraId(0); // Use a specific camera of the device // integrator.setBeepEnabled(false); // integrator.setBarcodeImageEnabled(true); // integrator.initiateScan(); IntentIntegrator.forSupportFragment(this) .setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES) .setPrompt("Scan a barcode") .setCameraId(0) .setBeepEnabled(false) .setBarcodeImageEnabled(true) .setOrientationLocked(false) .initiateScan(); }
public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); String scanResultRaw = scanResult.toString(); String splitData[] = scanResultRaw.split("\\r\\n|\\n|\\r"); if (splitData[0].substring(8).equals("null")) { //Display error as a toast Toast.makeText(getApplicationContext(), "Barcode not found.", Toast.LENGTH_SHORT).show(); //Disable confirm button confirmButton.setText("Scan to continue"); confirmButton.setEnabled(false); } else { extraInfo.setText(scanResultRaw); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == IntentIntegrator.REQUEST_CODE) { /* ** If result code is OK, it means a QR CODE has been read ** So we have to parse the content and to add an Account into our list */ if (resultCode == RESULT_OK) { OtpURL url = new OtpURL(data.getStringExtra("SCAN_RESULT")); if (!url.parse()) { Snackbar.make(findViewById(R.id.content_main), "QR Code invalide", Snackbar.LENGTH_LONG).show(); return; } if (!Preferences.get(this).addItem(new ReplicatorItem(url.secret, url.issuer, url.account, url.digits))) Snackbar.make(findViewById(R.id.content_main), "La clé du compte a été mise à jour", Snackbar.LENGTH_LONG).show(); else Snackbar.make(findViewById(R.id.content_main), "Compte ajouté", Snackbar.LENGTH_LONG).show(); if (Preferences.get(this).getItems().size() > 0) txt_no_account.setVisibility(View.INVISIBLE); adapter.clear(); adapter.addAll(Preferences.get(this).getItems()); adapter.notifyDataSetChanged(); } } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IntentIntegrator.REQUEST_CODE && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); String commands = extras.getString( Intents.Scan.RESULT); JSONObject jsonCommands = null; try { jsonCommands = new JSONObject(commands); if (startOrEnd == 's') { this.startStation = jsonCommands.getInt("startStation"); ((TextView) findViewById(R.id.commandOutTextView)).setText(commands); } else { this.endStation = jsonCommands.getInt("endStation"); } } catch (JSONException e) { e.printStackTrace(); } } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult != null && scanResult.getContents() != null) { String url = scanResult.getContents(); try { new URL(url); urlEditText.setText(url); } catch(MalformedURLException e) { AlertDialog alertDialog = createAlertDialog(this, "Not an URL", "The read QRCode does not represent a valid URL.", null, 1, "Ok", null, null); alertDialog.show(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) this.findViewById(R.id.button); final Activity activity = this; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { IntentIntegrator integrator = new IntentIntegrator(activity); integrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES); integrator.setPrompt("Scan"); integrator.setCameraId(0); integrator.setBeepEnabled(false); integrator.setBarcodeImageEnabled(false); integrator.initiateScan(); } }); }
@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, "Cancelled", Toast.LENGTH_LONG).show(); } else { Log.d("MainActivity", "Scanned"); Toast.makeText(this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show(); } } else { // This is important, otherwise the result will not be passed to the fragment super.onActivityResult(requestCode, resultCode, data); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if(intentResult!= null){ if(intentResult.getContents()==null){ Toast.makeText(this,"Scanning Stopped", Toast.LENGTH_LONG).show(); }else { Toast.makeText(this, intentResult.getContents(), Toast.LENGTH_SHORT).show(); } }else { super.onActivityResult(requestCode, resultCode, data); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case IntentIntegrator.REQUEST_CODE: onBarcodeResult(requestCode, resultCode, data); break; case REQUEST_CODE_EDIT_LOCATION: onEditLocationResult(data); break; } return; } super.onActivityResult(requestCode, resultCode, data); }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); // Insert/Update Food. if (id == R.id.action_save_food) { saveFood(); } else if (id == R.id.action_scan_barcode) { //Toast.makeText(getActivity(), "Functionality coming soon", Toast.LENGTH_SHORT).show(); IntentIntegrator integrator = new IntentIntegrator(getActivity()); integrator.initiateScan(); } else if (id == R.id.action_delete_food) { onFoodDelete(); } return super.onOptionsItemSelected(item); }
/** * Receive the Barcode Scanner Intent * */ public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); Uri uri; try { uri = Uri.parse(scanResult != null ? scanResult.getContents() : null); // this apparently prevents NullPointerException. Somehow. } catch (NullPointerException e) { Toast.makeText(getApplicationContext(), R.string.no_qrcode, Toast.LENGTH_SHORT).show(); return; } String busStopID = getBusStopIDFromUri(uri); busStopSearchByIDEditText.setText(busStopID); new asyncWgetBusStopFromBusStopID(busStopID, ArrivalFetchersRecursionHelper, lastSuccessfullySearchedBusStop); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == IntentIntegrator.REQUEST_CODE) { if (resultCode == RESULT_OK) { IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); Toast.makeText(this, result.getContents(), Toast.LENGTH_SHORT).show(); String[] parsedTuringData = result.getContents().split(":"); new TestRequestTask().execute(parsedTuringData); } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "QR Scanning cancelled", Toast.LENGTH_SHORT).show(); } } }
protected boolean handleIntent(Intent intent) { if (intent != null && intent.getAction().equals(ACTION_VERIFY_CONTACT)) { this.mAccount = extractAccount(intent); if (this.mAccount == null) { return false; } try { this.mConversation = this.xmppConnectionService.find(this.mAccount, Jid.fromString(intent.getExtras().getString("contact"))); if (this.mConversation == null) { return false; } } catch (final InvalidJidException ignored) { return false; } this.mode = intent.getIntExtra("mode", MODE_MANUAL_VERIFICATION); if (this.mode == MODE_SCAN_FINGERPRINT) { new IntentIntegrator(this).initiateScan(); return false; } return true; } else { return false; } }