2 Replies Latest reply on Dec 9, 2013 5:19 AM by Adel Sari

    Barcode scanner API

    Adel Sari

      Hi every one,

      is there a code example explaining how to use the barcode scanner on Concierge.

      thanks

        • Re: Barcode scanner API

          Hi Adel,

           

          We're going to start adding sample code for these types of features into the Concierge SDK. That said, here is a quick snippet to explain what you're looking for...

           

          Barcode scans are considered to be first-class events on Concierge in the same way that keyboard strokes or touch events are. As such, the foreground application is given the right of first refusal to the barcode scan via a callback in the Activity class. The code below illustrates this:

           

          public class MainActivity extends Activity implements BarcodeScanEvent.Callback

          {

           

            ... implement your Activity as usual here ...

           

            @Override

            public boolean onBarcodeScan(BarcodeScanEvent evt)

            {

              Toast.makeText(this, evt.getCharacters(), Toast.LENGTH_SHORT).show();

              return true;

            }

          }

           

          If the foreground Activity either does not implement the onBarcodeScan callback or returns false, then the event is fired as an Intent to the rest of the system for other Activities to handle. You can filter for this Intent using the following sample from an AndroidManifest.xml file:

           

                  <activity

                      android:name=".BarcodeScanInterceptor"

                      android:label="@string/barcode_scan_interceptor_title" >

           

                      <!-- Intent filter to view a upc -->

                      <intent-filter>

                          <action android:name="android.intent.action.VIEW" />

                          <category android:name="android.intent.category.DEFAULT" />

                          <data android:mimeType="text/upc" />

                      </intent-filter>

                  </activity>

           

          I hope this answers your question!

           

          Thanks.