2 Replies Latest reply on Jun 9, 2014 9:58 AM by Daniel Silva

    Android SDK - Scan via BroadCastReceiver

    Eugene Bosikov

      I have a very simple application that can work with any scanner via standard Android feature "BroadcastReceiver".

      Unfortunately, I could not find in documentation, what SendBroadCast ACTION happen when scan barcode on scanner MC67 and etc.

      I need ACTION NAME, for example "com.symbol.SCAN_ACTION" and what GetEXTRA anme for scanned data , for example "com.symbol.SCAN_EXTRA".

      I tried to setup DataWedge as Broadcast receiver, it doesn't give me any help.

      Also I tried to disable DataWedge -  however it still popup DEMO application.

      If this feature doesn't exist and scan event doesn't send brodcast, I need some documentation how to use SDK to create own application to create own broadcast send option.

      Also will be helpful to have one SDK documentation with sample codes (Not datawedge implementation)


      FYI: My application is not using to fillout and EditTexts, All operations happen on background via BroadCastReciver, nothing must not be started by default and etc...

      For now, If even I disabled DataWedge and Demo app, it still run these apps and popup a screen of demo app, this is not acceptable.  

        • Re: Android SDK - Scan via BroadCastReceiver
          Eugene Bosikov

          I want to use this logic and I'm not able to do DataWedge configuration, looks like this scenario doesn't work


          package com.motorolasolutions.emdk.sample.dwdemosample;



          import android.os.Bundle;

          import android.app.Activity;

          import android.content.BroadcastReceiver;

          import android.content.Context;

          import android.content.Intent;

          import android.content.IntentFilter;

          import android.view.View;

          import android.widget.TextView;

          import android.widget.Button;







          public class MainActivity extends Activity {


              private static final String DATA_STRING_TAG = "com.motorolasolutions.emdk.datawedge.data_string";




            private IntentFilter fltIntentAction ;

            private BroadcastReceiver _newItemsReceiver;



            private int iCount = 0;


              public void onCreate(Bundle savedInstanceState) {






              // Let's set the cursor at the end of any text in the editable text field

                  TextView et = (TextView)findViewById(R.id.editbox);

                  et.setText("Scan Now!");


                  final Button btn = (Button)findViewById(R.id.button1);

                  btn.setOnClickListener(new View.OnClickListener() {

                      public void onClick(View v) {

                          // Perform action on click


                      Intent intent = new Intent();


                          intent.putExtra(DATA_STRING_TAG, String.format("Test broadcast! #%d", iCount));






                  _newItemsReceiver = new BroadcastReceiver() {  



                 public void onReceive(Context context, Intent intent) {




              // get the data from the intent

                     String data = intent.getStringExtra(DATA_STRING_TAG);


                     // let's get our edit box view

                      TextView et = (TextView)findViewById(R.id.editbox);







                  fltIntentAction = new IntentFilter(getString(R.string.intentAction));


                  registerReceiver(_newItemsReceiver, fltIntentAction);




            protected void onDestroy() {


            // unregister the notifications






            • Re: Android SDK - Scan via BroadCastReceiver
              Daniel Silva

              If I understand you correctly, I think you would like Datawedge to send scan data to your app via an intent.  You can configure Datawedge to do this.  Typically you will need to set up a profile in datawedge that is associated to your app (or an activity in your app).  You would also want to disable keystroke output in this profile. Then, when that app/activity is in the foreground, scan data will be sent via the intent that you configure.  See the integrator's guide in the section on Datawedge.



              If you want scan data to go to your app/activity even if it is not in the foreground, I think you would want to modify Profile0 (the default profile).  If you set that one up to send the intent that you want, datawedge should do that if a barcode is scanned and there is no other profile set up that is associated to whatever app is in the foreground.


              I think by default the "Launcher" profile is set to send data via intent to the DWDEMO app.  So if you scan on the app launcher or home screen, that is why you will see dwdemo come up. If you always want scan data to go to your app, you might want to modify or delete the "Launcher" profile also.


              Note that we also recently released our EMDK v2.0 which gives you the ability to configure these profiles and control them from your app, if you need that level of control.