com.google.zxing.client.android.Intents Java Examples
The following examples show how to use
com.google.zxing.client.android.Intents.
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: QRCodeEncoder.java From barcodescanner-lib-aar with MIT License | 6 votes |
private void encodeContentsFromZXingIntent(Intent intent) { // Default to QR_CODE if no format given. String formatString = intent.getStringExtra(Intents.Encode.FORMAT); format = null; if (formatString != null) { try { format = BarcodeFormat.valueOf(formatString); } catch (IllegalArgumentException iae) { // Ignore it then } } if (format == null || format == BarcodeFormat.QR_CODE) { String type = intent.getStringExtra(Intents.Encode.TYPE); if (type != null && !type.isEmpty()) { this.format = BarcodeFormat.QR_CODE; encodeQRCodeContents(intent, type); } } else { String data = intent.getStringExtra(Intents.Encode.DATA); if (data != null && !data.isEmpty()) { contents = data; displayContents = data; title = activity.getString(R.string.contents_text); } } }
Example #2
Source File: ScannerActivity.java From privacy-friendly-qr-scanner with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scanner); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); permissionNeededExplanation = findViewById(R.id.activity_scanner_permission_needed_explanation); barcodeScannerView = findViewById(R.id.zxing_barcode_scanner); barcodeScannerView.getBarcodeView().addStateListener(stateListener); beepManager = new BeepManager(this); if (!getIntent().getBooleanExtra(Intents.Scan.BEEP_ENABLED, true) && preferences.getBoolean("pref_enable_beep_on_scan", true)) { beepManager.setBeepEnabled(false); } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { initScanWithPermissionCheck(); } else { initScan(); } }
Example #3
Source File: EncodeActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null) { finish(); } else { String action = intent.getAction(); if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) { setContentView(R.layout.encode); } else { finish(); } } }
Example #4
Source File: HistoryActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { if (adapter.getItem(position).getResult() != null) { Intent intent = new Intent(this, CaptureActivity.class); intent.putExtra(Intents.History.ITEM_NUMBER, position); setResult(Activity.RESULT_OK, intent); finish(); } }
Example #5
Source File: EncodeActivity.java From reacteu-app with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(fakeR.getId("menu", "encode"), menu); boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard(); int encodeNameResource = useVcard ? fakeR.getId("string", "menu_encode_mecard") : fakeR.getId("string", "menu_encode_vcard"); MenuItem encodeItem = menu.findItem(fakeR.getId("id", "menu_encode")); encodeItem.setTitle(encodeNameResource); Intent intent = getIntent(); if (intent != null) { String type = intent.getStringExtra(Intents.Encode.TYPE); encodeItem.setVisible(Contents.Type.CONTACT.equals(type)); } return super.onCreateOptionsMenu(menu); }
Example #6
Source File: ShareActivity.java From reacteu-app with MIT License | 5 votes |
private void showTextAsBarcode(String text) { Log.i(TAG, "Showing text as barcode: " + text); if (text == null) { return; // Show error? } Intent intent = new Intent(Intents.Encode.ACTION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); startActivity(intent); }
Example #7
Source File: QRCodeEncoder.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private boolean encodeContentsFromZXingIntent(Intent intent) { // Default to QR_CODE if no format given. String formatString = intent.getStringExtra(Intents.Encode.FORMAT); format = null; if (formatString != null) { try { format = BarcodeFormat.valueOf(formatString); } catch (IllegalArgumentException iae) { // Ignore it then } } if (format == null || format == BarcodeFormat.QR_CODE) { String type = intent.getStringExtra(Intents.Encode.TYPE); if (type == null || type.isEmpty()) { return false; } this.format = BarcodeFormat.QR_CODE; encodeQRCodeContents(intent, type); } else { String data = intent.getStringExtra(Intents.Encode.DATA); if (data != null && !data.isEmpty()) { contents = data; displayContents = data; title = activity.getString(R.string.contents_text); } } return contents != null && !contents.isEmpty(); }
Example #8
Source File: ShareActivity.java From weex with Apache License 2.0 | 5 votes |
private void launchSearch(String text) { Intent intent = new Intent(Intents.Encode.ACTION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); startActivity(intent); }
Example #9
Source File: ShareActivity.java From reacteu-app with MIT License | 5 votes |
private void launchSearch(String text) { Intent intent = new Intent(Intents.Encode.ACTION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); startActivity(intent); }
Example #10
Source File: EncodeActivity.java From barcodescanner-lib-aar with MIT License | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null) { finish(); } else { String action = intent.getAction(); if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) { setContentView(R.layout.encode); } else { finish(); } } }
Example #11
Source File: EncodeActivity.java From barcodescanner-lib-aar with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.encode, menu); boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard(); int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard; MenuItem encodeItem = menu.findItem(R.id.menu_encode); encodeItem.setTitle(encodeNameResource); Intent intent = getIntent(); if (intent != null) { String type = intent.getStringExtra(Intents.Encode.TYPE); encodeItem.setVisible(Contents.Type.CONTACT.equals(type)); } return super.onCreateOptionsMenu(menu); }
Example #12
Source File: QRCodeEncoder.java From barcodescanner-lib-aar with MIT License | 5 votes |
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException { this.activity = activity; this.dimension = dimension; this.useVCard = useVCard; String action = intent.getAction(); if (Intents.Encode.ACTION.equals(action)) { encodeContentsFromZXingIntent(intent); } else if (Intent.ACTION_SEND.equals(action)) { encodeContentsFromShareIntent(intent); } }
Example #13
Source File: HistoryManager.java From barcodescanner-lib-aar with MIT License | 5 votes |
public void addHistoryItem(Result result, ResultHandler handler) { // Do not save this item to the history if the preference is turned off, or the contents are // considered secure. if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) || handler.areContentsSecure() || !enableHistory) { return; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) { deletePrevious(result.getText()); } ContentValues values = new ContentValues(); values.put(DBHelper.TEXT_COL, result.getText()); values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString()); values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString()); values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis()); SQLiteOpenHelper helper = new DBHelper(activity); SQLiteDatabase db = null; try { db = helper.getWritableDatabase(); // Insert the new entry into the DB. db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values); } finally { close(null, db); } }
Example #14
Source File: HistoryManager.java From android-apps with MIT License | 5 votes |
public void addHistoryItem(Result result, ResultHandler handler) { // Do not save this item to the history if the preference is turned off, or the contents are // considered secure. if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) || handler.areContentsSecure()) { return; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) { deletePrevious(result.getText()); } ContentValues values = new ContentValues(); values.put(DBHelper.TEXT_COL, result.getText()); values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString()); values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString()); values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis()); SQLiteOpenHelper helper = new DBHelper(activity); SQLiteDatabase db = null; try { db = helper.getWritableDatabase(); // Insert the new entry into the DB. db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values); } finally { close(null, db); } }
Example #15
Source File: HistoryActivity.java From barcodescanner-lib-aar with MIT License | 5 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { if (adapter.getItem(position).getResult() != null) { Intent intent = new Intent(this, CaptureActivity.class); intent.putExtra(Intents.History.ITEM_NUMBER, position); setResult(Activity.RESULT_OK, intent); finish(); } }
Example #16
Source File: QRCodeEncoder.java From android-apps with MIT License | 5 votes |
QRCodeEncoder(Activity activity, Intent intent, int dimension, boolean useVCard) throws WriterException { this.activity = activity; this.dimension = dimension; this.useVCard = useVCard; String action = intent.getAction(); if (action.equals(Intents.Encode.ACTION)) { encodeContentsFromZXingIntent(intent); } else if (action.equals(Intent.ACTION_SEND)) { encodeContentsFromShareIntent(intent); } }
Example #17
Source File: EncodeActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.encode, menu); boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard(); int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard; MenuItem encodeItem = menu.findItem(R.id.menu_encode); encodeItem.setTitle(encodeNameResource); Intent intent = getIntent(); if (intent != null) { String type = intent.getStringExtra(Intents.Encode.TYPE); encodeItem.setVisible(Contents.Type.CONTACT.equals(type)); } return super.onCreateOptionsMenu(menu); }
Example #18
Source File: QRCodeEncoder.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException { this.activity = activity; this.dimension = dimension; this.useVCard = useVCard; String action = intent.getAction(); if (Intents.Encode.ACTION.equals(action)) { encodeContentsFromZXingIntent(intent); } else if (Intent.ACTION_SEND.equals(action)) { encodeContentsFromShareIntent(intent); } }
Example #19
Source File: ShareActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void showTextAsBarcode(String text) { Log.i(TAG, "Showing text as barcode: " + text); if (text == null) { return; // Show error? } Intent intent = new Intent(Intents.Encode.ACTION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); startActivity(intent); }
Example #20
Source File: ShareActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void launchSearch(String text) { Intent intent = new Intent(Intents.Encode.ACTION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); startActivity(intent); }
Example #21
Source File: SearchBookContentsActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }
Example #22
Source File: HistoryManager.java From weex with Apache License 2.0 | 5 votes |
public void addHistoryItem(Result result, ResultHandler handler) { // Do not save this item to the history if the preference is turned off, or the contents are // considered secure. if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true) || handler.areContentsSecure() || !enableHistory) { return; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); if (!prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false)) { deletePrevious(result.getText()); } ContentValues values = new ContentValues(); values.put(DBHelper.TEXT_COL, result.getText()); values.put(DBHelper.FORMAT_COL, result.getBarcodeFormat().toString()); values.put(DBHelper.DISPLAY_COL, handler.getDisplayContents().toString()); values.put(DBHelper.TIMESTAMP_COL, System.currentTimeMillis()); SQLiteOpenHelper helper = new DBHelper(activity); SQLiteDatabase db = null; try { db = helper.getWritableDatabase(); // Insert the new entry into the DB. db.insert(DBHelper.TABLE_NAME, DBHelper.TIMESTAMP_COL, values); } finally { close(null, db); } }
Example #23
Source File: HistoryActivity.java From weex with Apache License 2.0 | 5 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { if (adapter.getItem(position).getResult() != null) { Intent intent = new Intent(this, CaptureActivity.class); intent.putExtra(Intents.History.ITEM_NUMBER, position); setResult(Activity.RESULT_OK, intent); finish(); } }
Example #24
Source File: QRCodeEncoder.java From reacteu-app with MIT License | 5 votes |
private boolean encodeContentsFromZXingIntent(Intent intent) { // Default to QR_CODE if no format given. String formatString = intent.getStringExtra(Intents.Encode.FORMAT); format = null; if (formatString != null) { try { format = BarcodeFormat.valueOf(formatString); } catch (IllegalArgumentException iae) { // Ignore it then } } if (format == null || format == BarcodeFormat.QR_CODE) { String type = intent.getStringExtra(Intents.Encode.TYPE); if (type == null || type.length() == 0) { return false; } this.format = BarcodeFormat.QR_CODE; encodeQRCodeContents(intent, type); } else { String data = intent.getStringExtra(Intents.Encode.DATA); if (data != null && data.length() > 0) { contents = data; displayContents = data; title = activity.getString(fakeR.getId("string", "contents_text")); } } return contents != null && contents.length() > 0; }
Example #25
Source File: QRCodeEncoder.java From weex with Apache License 2.0 | 5 votes |
private boolean encodeContentsFromZXingIntent(Intent intent) { // Default to QR_CODE if no format given. String formatString = intent.getStringExtra(Intents.Encode.FORMAT); format = null; if (formatString != null) { try { format = BarcodeFormat.valueOf(formatString); } catch (IllegalArgumentException iae) { // Ignore it then } } if (format == null || format == BarcodeFormat.QR_CODE) { String type = intent.getStringExtra(Intents.Encode.TYPE); if (type == null || type.isEmpty()) { return false; } this.format = BarcodeFormat.QR_CODE; encodeQRCodeContents(intent, type); } else { String data = intent.getStringExtra(Intents.Encode.DATA); if (data != null && !data.isEmpty()) { contents = data; displayContents = data; title = activity.getString(R.string.contents_text); } } return contents != null && !contents.isEmpty(); }
Example #26
Source File: QRCodeEncoder.java From weex with Apache License 2.0 | 5 votes |
QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException { this.activity = activity; this.dimension = dimension; this.useVCard = useVCard; String action = intent.getAction(); if (action.equals(Intents.Encode.ACTION)) { encodeContentsFromZXingIntent(intent); } else if (action.equals(Intent.ACTION_SEND)) { encodeContentsFromShareIntent(intent); } }
Example #27
Source File: EncodeActivity.java From weex with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.encode, menu); boolean useVcard = qrCodeEncoder != null && qrCodeEncoder.isUseVCard(); int encodeNameResource = useVcard ? R.string.menu_encode_mecard : R.string.menu_encode_vcard; MenuItem encodeItem = menu.findItem(R.id.menu_encode); encodeItem.setTitle(encodeNameResource); Intent intent = getIntent(); if (intent != null) { String type = intent.getStringExtra(Intents.Encode.TYPE); encodeItem.setVisible(Contents.Type.CONTACT.equals(type)); } return super.onCreateOptionsMenu(menu); }
Example #28
Source File: EncodeActivity.java From weex with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Intent intent = getIntent(); if (intent == null) { finish(); } else { String action = intent.getAction(); if (Intents.Encode.ACTION.equals(action) || Intent.ACTION_SEND.equals(action)) { setContentView(R.layout.encode); } else { finish(); } } }
Example #29
Source File: ShareActivity.java From weex with Apache License 2.0 | 5 votes |
private void showTextAsBarcode(String text) { Log.i(TAG, "Showing text as barcode: " + text); if (text == null) { return; // Show error? } Intent intent = new Intent(Intents.Encode.ACTION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT); intent.putExtra(Intents.Encode.DATA, text); intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString()); startActivity(intent); }
Example #30
Source File: SearchBookContentsActivity.java From weex with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Make sure that expired cookies are removed on launch. CookieSyncManager.createInstance(this); CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (LocaleManager.isBookSearchUrl(isbn)) { setTitle(getString(R.string.sbc_name)); } else { setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn); } setContentView(R.layout.search_book_contents); queryTextView = (EditText) findViewById(R.id.query_text_view); String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY); if (initialQuery != null && !initialQuery.isEmpty()) { // Populate the search box but don't trigger the search queryTextView.setText(initialQuery); } queryTextView.setOnKeyListener(keyListener); queryButton = findViewById(R.id.query_button); queryButton.setOnClickListener(buttonListener); resultListView = (ListView) findViewById(R.id.result_list_view); LayoutInflater factory = LayoutInflater.from(this); headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false); resultListView.addHeaderView(headerView); }