Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a sample code: my app uses ZXing Barcode Scanner.</p> <ol> <li><p>You need these 2 classes: <a href="http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java">IntentIntegrator</a> and <a href="http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java">IntentResult</a></p></li> <li><p>Call scanner (e.g. OnClickListener, OnMenuItemSelected...), "PRODUCT_MODE" - it scans standard 1D barcodes (you can add more).:</p> <pre><code>IntentIntegrator.initiateScan(this, "Warning", "ZXing Barcode Scanner is not installed, download?", "Yes", "No", "PRODUCT_MODE"); </code></pre></li> <li><p>Get barcode as a result:</p> <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case IntentIntegrator.REQUEST_CODE: if (resultCode == Activity.RESULT_OK) { IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (intentResult != null) { String contents = intentResult.getContents(); String format = intentResult.getFormatName(); this.elemQuery.setText(contents); this.resume = false; Log.d("SEARCH_EAN", "OK, EAN: " + contents + ", FORMAT: " + format); } else { Log.e("SEARCH_EAN", "IntentResult je NULL!"); } } else if (resultCode == Activity.RESULT_CANCELED) { Log.e("SEARCH_EAN", "CANCEL"); } } } </code></pre></li> </ol> <p><strong>contents</strong> holds barcode number</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload