3 Replies Latest reply on Sep 25, 2014 6:50 AM by Raphael Dantas

    [TC55] Creating profile with EMDK Manager and importing it to DataWedge

    Raphael Dantas

      Hello,

       

      I have an issue with a profile created with the EMDK Manager in Eclipse.

       

      I have filled the infos for the Intent like this :

       

      emdk.png

       

      And deactivated the Keystroke part :

       

      emdk2.png

       

      The XML is well generated in the assets folder.

       

      And then in my Activity I use this code below to import my profile :

       

      package com.test.kiwapp.motorola;
      
      
      import android.app.Activity;
      import android.content.Context;
      import android.content.Intent;
      import android.os.Bundle;
      import android.util.Log;
      import android.view.View;
      import android.view.View.OnClickListener;
      import android.widget.EditText;
      import android.widget.ImageView;
      import android.widget.TextView;
      import android.widget.Toast;
      
      
      import com.symbol.emdk.EMDKManager;
      import com.symbol.emdk.EMDKManager.EMDKListener;
      import com.symbol.emdk.EMDKResults;
      import com.symbol.emdk.ProfileConfig;
      import com.symbol.emdk.ProfileManager;
      
      
      
      
      public class MainActivity extends Activity {
        // Tag used for logging errors
        private static final String TAG = MainActivity.class.getSimpleName();
      
      
        // Let's define some intent strings
        // This intent string contains the source of the data as a string
        private static final String SOURCE_TAG = "com.motorolasolutions.emdk.datawedge.source";
        // This intent string contains the barcode symbology as a string
        private static final String LABEL_TYPE_TAG = "com.motorolasolutions.emdk.datawedge.label_type";
      
      
        // This intent string contains the captured data as a string
        // (in the case of MSR this data string contains a concatenation of the
        // track data)
        private static final String DATA_STRING_TAG = "com.motorolasolutions.emdk.datawedge.data_string";
      
      
        // Let's define the API intent strings for the soft scan trigger
        private static final String ACTION_SOFTSCANTRIGGER = "com.motorolasolutions.emdk.datawedge.api.ACTION_SOFTSCANTRIGGER";
        private static final String EXTRA_PARAM = "com.motorolasolutions.emdk.datawedge.api.EXTRA_PARAMETER";
        private static final String DWAPI_START_SCANNING = "START_SCANNING";
        private static final String DWAPI_STOP_SCANNING = "STOP_SCANNING";
        private static final String DWAPI_TOGGLE_SCANNING = "TOGGLE_SCANNING";
      
      
        private static String ourIntentAction = "com.test.kiwapp.motorola.RECVR";
      
      
        private ProfileManager profileManager;
      
      
        private static final String MOTOROLA_SCAN_PROFILE_NAME = "KiwappTest";
      
      
        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
      
      
        ourIntentAction = getString(R.string.intentAction);
      
      
        // Since we will be using the image as a soft scan trigger toggle button
        // let's handle the image on onClick event
        ImageView img = (ImageView) findViewById(R.id.logo);
        img.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
        // the image has been tapped so shoot off the intent to
        // DataWedge
        // to toggle the soft scan trigger
        // Create a new intent
        Intent i = new Intent();
        // set the intent action using soft scan trigger action string
        // declared earlier
        i.setAction(ACTION_SOFTSCANTRIGGER);
        // add a string parameter to tell DW that we want to toggle the
        // soft scan trigger
        i.putExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING);
        // now broadcast the intent
        MainActivity.this.sendBroadcast(i);
        // provide some feedback to the user that we did something
        Toast.makeText(v.getContext(), "Soft scan trigger toggled.",
        Toast.LENGTH_SHORT).show();
        }
        });
      
      
        initMotorola();
        }
      
      
        // We need to handle any incoming intents, so let override the onNewIntent
        // method
        @Override
        public void onNewIntent(Intent i) {
        handleDecodeData(i);
        }
      
      
        // This function is responsible for getting the data from the intent
        // formatting it and adding it to the end of the edit box
        private void handleDecodeData(Intent intent) {
        // check the intent action is for us
        if (intent.getAction().contentEquals(ourIntentAction)) {
        // get the data from the intent
        String data = intent.getStringExtra(DATA_STRING_TAG);
        String labelType = "";
      
      
        // check if there is anything in the data
        if (data != null && data.length() > 0) {
        // we have some data, so let's get it's symbology
        labelType = intent.getStringExtra(LABEL_TYPE_TAG);
        // check if the string is empty
        if (labelType != null && labelType.length() > 0) {
        // format of the label type string is LABEL-TYPE-SYMBOLOGY
        // so let's skip the LABEL-TYPE- portion to get just the
        // symbology
        labelType = labelType.substring(11);
        } else {
        // the string was empty so let's set it to "Unknown"
        labelType = "Unknown";
        }
        }
      
      
        Log.i(TAG, "==> " + data);
        Toast.makeText(getApplicationContext(), data, Toast.LENGTH_SHORT)
        .show();
        }
      
      
        }
      
      
        private void initMotorola() {
      
      
        final Context ctx = this.getApplicationContext();
      
      
        // The EMDKManager object will be created and returned in the callback.
        EMDKResults results = EMDKManager.getEMDKManager(ctx,
        new EMDKListener() {
      
      
        @Override
        public void onOpened(EMDKManager emdkManager) {
      
      
        // Create the Profile Config object
        ProfileConfig profileConfigObj = new ProfileConfig();
      
      
        // Get the ProfileManager object to process the profiles
        profileManager = (ProfileManager) emdkManager
        .getInstance(EMDKManager.FEATURE_TYPE.PROFILE);
      
      
        if (profileManager != null) {
        EMDKResults results = profileManager
        .processProfile(MOTOROLA_SCAN_PROFILE_NAME,
        ProfileManager.PROFILE_FLAG.SET,
        profileConfigObj);
        if (results.statusCode == EMDKResults.STATUS_CODE.SUCCESS) {
        Toast.makeText(ctx,
        "App successfully installed...",
        Toast.LENGTH_SHORT).show();
        } else {
        Toast.makeText(ctx,
        "Profile initilization failed",
        Toast.LENGTH_SHORT).show();
        }
        }
        }
      
      
        @Override
        public void onClosed() {
        // TODO Auto-generated method stub
      
      
        }
        });
      
      
        // Check the return status of getEMDKManager
        if (results.statusCode == EMDKResults.STATUS_CODE.SUCCESS) {
        // EMDKManager object creation success
        Log.i(TAG, "getEMDKManager => OK");
        } else {
        // EMDKManager object creation failed
        Log.e(TAG, "getEMDKManager => KO");
        }
        }
      
      
      }
      

       

       

      But when I check the profile imported in DataWedge, I still see the Keystroke part enabled  :

       

      datawedge2.png

       

      And the infos of the Intent are not present and it's not enabled !

       

      datawedge3.png

       

       

       

      So what's wrong with my code ? Is it a bug from DataWedge ?

       

      Thanks for your help.