9 Replies Latest reply on Sep 14, 2015 7:59 AM by John Foley

    Enabling and disabling the scanner and msr

    John Foley

      My application has the need to enable and disable both the scanner and the msr at various points throughout a sequence of operations.  For example, there are situations where scanner input is allowed but MSR input is not.  My plan for implementing this behavior was to create a profile with characteristic type "MSR", emdk_name="theMsr"  that initially has msr_input_enabled set to false and a characteristic type "Barcode", emdk_name="theScanner" that has scanner_input_enabled also set to false.

       

      Then at the appropriate type I call processProfileAsync with name/value pair as follows:

       

           to enable scanner: theScanner.scanner_input_enabled=true

           to disable scanner: theScanner.scanner_input_enabled=false

           to enable msr:theMsr.msr_input_enabled=true

           to disable msr: theMsr.msr_input_enabled=false

       

      Every time I call processProfileAsync the onData callback indicates success but it does not work reliably.  Also, it seems to take upwards of one second to process the profile.  My application needs to be able to switch the scanner and msr off/on very quickly and this one second delay is causing me problems.

       

      WRT to reliability:  It seems if you call processProfile twice in rapid succession there are problems.  If I try to enable both devices by clicking the checkboxes as fast as I can I only get one onData callback (shouldn't I be getting two? one for each processProfile call) and it is random whether both devices will be enabled.  Sometimes the scanner gets enabled sometimes the MSR.  Same with disabling.   the onData callback says the operation worked but the scanner is still enabled. 

       

      I wrote a simple test program that has check boxes to enable and disable the devices.  What am I doing wrong?

      Attached is project demonstrating the issues I'm seeing.  Inline are my main activity source and profile.

       

      Thanks

       

       

      Start MainActivity.java-----------------------------------------

      package com.example.johnfoley.myapplication;

       

      import android.app.Activity;

      import android.content.Intent;

      import android.os.Bundle;

      import android.util.Log;

      import android.view.Menu;

      import android.view.MenuItem;

      import android.view.View;

      import android.widget.CheckBox;

      import android.widget.EditText;

       

      import com.symbol.emdk.EMDKManager;

      import com.symbol.emdk.EMDKManager.EMDKListener;

      import com.symbol.emdk.EMDKResults;

      import com.symbol.emdk.ProfileManager;

      import com.symbol.emdk.payment.PaymentManager;

       

      import static com.symbol.emdk.ProfileManager.CreateNameValuePair;

       

      public class MainActivity extends Activity implements EMDKListener, ProfileManager.DataListener {

       

         private String profileName = "QVSProfile";

         private ProfileManager mProfileManager = null;

         private EMDKManager emdkManager = null;

       

       

         @Override
         protected void onCreate(Bundle savedInstanceState) {

         super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

         //The EMDKManager object will be created and returned in the callback.
         EMDKResults results = EMDKManager.getEMDKManager(getApplicationContext(), this);

       

         //Check the return status of getEMDKManager
         if (results.statusCode == EMDKResults.STATUS_CODE.FAILURE) {

        Log.d("", "getEMDKManager() failed");

        }

        }

       

         @Override
         public boolean onCreateOptionsMenu(Menu menu) {

         // Inflate the menu; this adds items to the action bar if it is present.
         getMenuInflater().inflate(R.menu.menu_main, menu);

         return true;

        }

       

         @Override
         public boolean onOptionsItemSelected(MenuItem item) {

         // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
         int id = item.getItemId();

       

         //noinspection SimplifiableIfStatement
         if (id == R.id.action_settings) {

         return true;

        }

       

         return super.onOptionsItemSelected(item);

        }

       

         @Override
         public void onOpened(EMDKManager emdkManager) {

         if (emdkManager != null) {

         //Get the ProfileManager object to process the profiles
         mProfileManager = (ProfileManager) emdkManager.getInstance(EMDKManager.FEATURE_TYPE.PROFILE);

       

         if (mProfileManager != null) {

         try {

         mProfileManager.addDataListener(this);

       

        EMDKResults results = mProfileManager.processProfileAsync(profileName, ProfileManager.PROFILE_FLAG.SET, (String[]) null);

         if (results.statusCode == EMDKResults.STATUS_CODE.FAILURE) {

        Log.d("", "processProfile() failed");

        }

        } catch (Exception ex) {

        Log.d("", "Exception in onOpened", ex);

        }

        }

        }

        }

       

         @Override
         public void onDestroy() {

         super.onDestroy();

         //Clean up the objects created by EMDK manager
         if (emdkManager != null)

         emdkManager.release();

        }

       

         @Override
         public void onClosed() {

        }

       

         public void onScannerEnabledClick(View view) {

         boolean checked = ((CheckBox) view).isChecked();

       

        String[] xtraData = new String[1];

        xtraData[0] = CreateNameValuePair("theScanner", "scanner_input_enabled", checked ? "true" : "false");

        EMDKResults results = mProfileManager.processProfileAsync(profileName, ProfileManager.PROFILE_FLAG.SET, xtraData);

       

        Log.d("","SCANCMD:" + xtraData[0]);

       

         if (results.statusCode == EMDKResults.STATUS_CODE.FAILURE) {

        Log.d("", "processProfile() scanner enable/disable failed");

        }

        }

       

         public void onMsrEnabledClick(View view) {

         boolean checked = ((CheckBox) view).isChecked();

       

        String[] xtraData = new String[1];

        xtraData[0] = CreateNameValuePair("theMsr", "msr_input_enabled", checked ? "true" : "false");

        EMDKResults results = mProfileManager.processProfileAsync(profileName, ProfileManager.PROFILE_FLAG.SET, xtraData);

       

        Log.d("","MSRCMD:" + xtraData[0]);

       

         if (results.statusCode == EMDKResults.STATUS_CODE.FAILURE) {

        Log.d("", "processProfile() msr enable/disable failed");

        }

        }

       

         @Override
         public void onData(ProfileManager.ResultData resultData) {

         if (resultData.getResult().statusCode == EMDKResults.STATUS_CODE.FAILURE) {

        Log.d("", "async process profile failed");

        } else {

        Log.d("", "async process profile succeeded");

        }

        }

       

         @Override
         public void onNewIntent(Intent i) {

        handleDecodeData(i);

        }

       

         private static final String SOURCE_TAG = "com.motorolasolutions.emdk.datawedge.source";

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

         private static final String LABEL_TYPE_TAG = "com.motorolasolutions.emdk.datawedge.label_type";

       

         private static int msrReadCount = 0;

       

         private void handleDecodeData(Intent i) {

         // check the intent action is for us
         if (i.getAction().contentEquals("com.example.johnfoley.myapplication.RECVR")) {

        String out = "";

         // get the source of the data
         String source = i.getStringExtra(SOURCE_TAG);

         // save it to use later
         if (source == null)

        source = "scanner";

       

       

        String data = i.getStringExtra(DATA_STRING_TAG);

       

       

        Integer data_len = 0;

         if (data != null)

        data_len = data.length();

       

         // check if the data has come from the barcode scanner
         if (source.equalsIgnoreCase("scanner")) {

         // 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
         String sLabelType = i.getStringExtra(LABEL_TYPE_TAG);

         // check if the string is empty
         if (sLabelType != null && sLabelType.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
         sLabelType = sLabelType.substring(11);

        } else {

         // the string was empty so let's set it to "Unknown"
         sLabelType = "Unknown";

        }

         // let's construct the beginning of our output string
         out = sLabelType + ":";

        }

        }

       

         // check if the data has come from the MSR
         if (source.equalsIgnoreCase("msr")) {

         msrReadCount++;

         // construct the beginning of our output string
         out = "(" + msrReadCount + ") ";

        }

       

         // let's get our edit box view
         EditText et = (EditText) findViewById(R.id.output);

        et.setText(out + data);

        }

        }

       

         public void onScannerData(String s) {

         // let's get our edit box view
         EditText et = (EditText) findViewById(R.id.output);

        et.setText(s);

        }

      }

       

      End MainActivity.java-----------------------------------------

       

      Start EMDKConfig.xml-----------------------------------------

      <?xml version="1.0" encoding="UTF-8"?><!--This is an auto generated document. Changes to this document may cause incorrect behavior.--><wap-provisioningdoc>

        <characteristic type="ProfileInfo">

        <parm name="created_wizard_version" value="3.1.20"/>

        </characteristic>

        <characteristic type="Profile">

        <parm name="ProfileName" value="QVSProfile"/>

        <parm name="ModifiedDate" value="2015-06-26 14:00:10"/>

        <parm name="TargetSystemVersion" value="4.4"/>

       

        <characteristic type="ActivitySelection" version="0.1">

        <parm name="emdk_name" value="ProfileActivity"/>

        <characteristic type="Application">

        <parm name="package" value="com.example.johnfoley.myapplication"/>

        <characteristic type="Activities">

        <parm name="activity" value="MainActivity"/>

        </characteristic>

        </characteristic>

        </characteristic>

        <characteristic type="MSR" version="0.1">

        <parm name="emdk_name" value="theMsr"/>

        <parm name="msr_input_enabled" value="false"/>

        </characteristic>

        <characteristic type="Barcode" version="3.1">

        <parm name="emdk_name" value="theScanner"/>

        <parm name="scanner_input_enabled" value="false"/>

        <parm name="ScannerSelection" value="AUTO"/>

        <characteristic type="Decoders">

        <parm name="decoder_upca" value="Default"/>

        <parm name="decoder_upce0" value="Default"/>

        <parm name="decoder_ean13" value="Default"/>

        <parm name="decoder_ean8" value="Default"/>

        <parm name="decoder_code128" value="Default"/>

        <parm name="decoder_code39" value="Default"/>

        <parm name="decoder_i2of5" value="Default"/>

        <parm name="decoder_gs1_databar" value="Default"/>

        <parm name="decoder_gs1_databar_lim" value="Default"/>

        <parm name="decoder_gs1_databar_exp" value="Default"/>

        <parm name="decoder_datamatrix" value="Default"/>

        <parm name="decoder_qrcode" value="Default"/>

        <parm name="decoder_pdf417" value="Default"/>

        <parm name="decoder_composite_ab" value="Default"/>

        <parm name="decoder_composite_c" value="Default"/>

        <parm name="decoder_microqr" value="Default"/>

        <parm name="decoder_aztec" value="Default"/>

        <parm name="decoder_maxicode" value="Default"/>

        <parm name="decoder_micropdf" value="Default"/>

        <parm name="decoder_uspostnet" value="Default"/>

        <parm name="decoder_usplanet" value="Default"/>

        <parm name="decoder_uk_postal" value="Default"/>

        <parm name="decoder_japanese_postal" value="Default"/>

        <parm name="decoder_australian_postal" value="Default"/>

        <parm name="decoder_canadian_postal" value="Default"/>

        <parm name="decoder_dutch_postal" value="Default"/>

        <parm name="decoder_us4state" value="Default"/>

        <parm name="decoder_us4state_fics" value="Default"/>

        <parm name="decoder_codabar" value="Default"/>

        <parm name="decoder_msi" value="Default"/>

        <parm name="decoder_code93" value="Default"/>

        <parm name="decoder_trioptic39" value="Default"/>

        <parm name="decoder_d2of5" value="Default"/>

        <parm name="decoder_chinese_2of5" value="Default"/>

        <parm name="decoder_korean_3of5" value="Default"/>

        <parm name="decoder_code11" value="Default"/>

        <parm name="decoder_tlc39" value="Default"/>

        <parm name="decoder_mailmark" value="Default"/>

        <parm name="decoder_hanxin" value="Default"/>

        <parm name="decoder_signature" value="Default"/>

        <parm name="decoder_webcode" value="Default"/>

        <parm name="decoder_matrix_2of5" value="Default"/>

        <parm name="decoder_upce1" value="Default"/>

        </characteristic>

        <characteristic type="DecoderParams">

        <characteristic type="UPCA">

        <parm name="decoder_upca_report_check_digit" value="Default"/>

        <parm name="decoder_upca_preamble" value="Default"/>

        </characteristic>

        <characteristic type="UPCE0">

        <parm name="decoder_upce0_report_check_digit" value="Default"/>

        <parm name="decoder_upce0_preamble" value="Default"/>

        <parm name="decoder_upce0_convert_to_upca" value="Default"/>

        </characteristic>

        <characteristic type="EAN8">

        <parm name="decoder_ean8_convert_to_ean13" value="Default"/>

        </characteristic>

        <characteristic type="Code128">

        <parm name="decoder_code128_length1" value="0"/>

        <parm name="decoder_code128_length2" value="55"/>

        <parm name="decoder_code128_redundancy" value="Default"/>

        <parm name="decoder_code128_enable_plain" value="Default"/>

        <parm name="decoder_code128_enable_ean128" value="Default"/>

        <parm name="decoder_code128_enable_isbt128" value="Default"/>

        <parm name="decoder_code128_isbt128_concat_mode" value="Default"/>

        <parm name="decoder_code128_check_isbt_table" value="Default"/>

        <parm name="decoder_code128_security_level" value="Default"/>

        <parm name="code128_enable_marginless_decode" value="Default"/>

        <parm name="code128_ignore_fnc4" value="Default"/>

        </characteristic>

        <characteristic type="Code39">

        <parm name="decoder_code39_length1" value="0"/>

        <parm name="decoder_code39_length2" value="55"/>

        <parm name="decoder_code39_verify_check_digit" value="Default"/>

        <parm name="decoder_code39_report_check_digit" value="Default"/>

        <parm name="decoder_code39_full_ascii" value="Default"/>

        <parm name="decoder_code39_redundancy" value="Default"/>

        <parm name="decoder_code39_convert_to_code32" value="Default"/>

        <parm name="decoder_code39_report_code32_prefix" value="Default"/>

        <parm name="decoder_code39_security_level" value="Default"/>

        <parm name="code39_enable_marginless_decode" value="Default"/>

        </characteristic>

        <characteristic type="Interleaved_2of5">

        <parm name="decoder_i2of5_length1" value="14"/>

        <parm name="decoder_i2of5_length2" value="10"/>

        <parm name="decoder_i2of5_redundancy" value="Default"/>

        <parm name="decoder_i2of5_check_digit" value="Default"/>

        <parm name="decoder_i2of5_report_check_digit" value="Default"/>

        <parm name="decoder_itf14_convert_to_ean13" value="Default"/>

        <parm name="decoder_i2of5_security_level" value="Default"/>

        <parm name="i20f5_enable_marginless_decode" value="Default"/>

        </characteristic>

        <characteristic type="GS1_Databar_Limited">

        <parm name="decoder_gs1_lim_security_level" value="Default"/>

        </characteristic>

        <characteristic type="Composite_AB">

        <parm name="decoder_composite_ab_ucc_link_mode" value="Default"/>

        </characteristic>

        <characteristic type="US_Postnet">

        <parm name="decoder_uspostnet_report_check_digit" value="Default"/>

        </characteristic>

        <characteristic type="US_Planet">

        <parm name="decoder_usplanet_report_check_digit" value="Default"/>

        </characteristic>

        <characteristic type="UK_Postal">

        <parm name="decoder_uk_postal_report_check_digit" value="Default"/>

        </characteristic>

        <characteristic type="Codabar">

        <parm name="decoder_codabar_length1" value="6"/>

        <parm name="decoder_codabar_length2" value="55"/>

        <parm name="decoder_codabar_redundancy" value="Default"/>

        <parm name="decoder_codabar_clsi_editing" value="Default"/>

        <parm name="decoder_codabar_notis_editing" value="Default"/>

        </characteristic>

        <characteristic type="MSI">

        <parm name="decoder_msi_length1" value="4"/>

        <parm name="decoder_msi_length2" value="55"/>

        <parm name="decoder_msi_redundancy" value="Default"/>

        <parm name="decoder_msi_check_digit" value="Default"/>

        <parm name="decoder_msi_check_digit_scheme" value="Default"/>

        <parm name="decoder_msi_report_check_digit" value="Default"/>

        </characteristic>

        <characteristic type="Code93">

        <parm name="decoder_code93_length1" value="0"/>

        <parm name="decoder_code93_length2" value="55"/>

        <parm name="decoder_code93_redundancy" value="Default"/>

        </characteristic>

        <characteristic type="Trioptic_39">

        <parm name="decoder_trioptic39_redundancy" value="Default"/>

        </characteristic>

        <characteristic type="Discrete_2of5">

        <parm name="decoder_d2of5_length1" value="0"/>

        <parm name="decoder_d2of5_length2" value="14"/>

        <parm name="decoder_d2of5_redundancy" value="Default"/>

        </characteristic>

        <characteristic type="Code11">

        <parm name="decoder_code11_length1" value="4"/>

        <parm name="decoder_code11_length2" value="55"/>

        <parm name="decoder_code11_redundancy" value="Default"/>

        <parm name="decoder_code11_verify_check_digit" value="Default"/>

        <parm name="decoder_code11_report_check_digit" value="Default"/>

        </characteristic>

        <characteristic type="Han_Xin">

        <parm name="decoder_hanxin_inverse" value="Default"/>

        </characteristic>

        <characteristic type="Matrix_2of5">

        <parm name="decoder_matrix_2of5_length1" value="10"/>

        <parm name="decoder_matrix_2of5_length2" value="0"/>

        <parm name="decoder_matrix_2of5_redundancy" value="Default"/>

        <parm name="decoder_matrix_2of5_report_check_digit" value="Default"/>

        <parm name="decoder_matrix_2of5_verify_check_digit" value="Default"/>

        </characteristic>

        <characteristic type="UPCE1">

        <parm name="decoder_upce1_report_check_digit" value="Default"/>

        <parm name="decoder_upce1_preamble" value="Default"/>

        <parm name="decoder_upce1_convert_to_upca" value="Default"/>

        </characteristic>

        </characteristic>

        <characteristic type="UpcEanParams">

        <parm name="upcean_security_level" value="Default"/>

        <parm name="upcean_supplemental2" value="Default"/>

        <parm name="upcean_supplemental5" value="Default"/>

        <parm name="upcean_supplemental_mode" value="Default"/>

        <parm name="upcean_retry_count" value="10"/>

        <parm name="upcean_random_weight_check_digit" value="Default"/>

        <parm name="upcean_linear_decode" value="Default"/>

        <parm name="upcean_bookland" value="Default"/>

        <parm name="upcean_coupon" value="Default"/>

        <parm name="upcean_coupon_report" value="Default"/>

        <parm name="upcean_ean_zero_extend" value="Default"/>

        <parm name="upcean_bookland_format" value="Default"/>

        <parm name="databar_to_upc_ean" value="Default"/>

        <parm name="upc_enable_marginless_decode" value="Default"/>

        </characteristic>

        <characteristic type="ReaderParams">

        <parm name="beam_timer" value="5000"/>

        <parm name="Adaptive_Scanning" value="Default"/>

        <parm name="Beam_Width" value="Default"/>

        <parm name="power_mode" value="Default"/>

        <parm name="mpd_mode" value="Default"/>

        <parm name="reader_mode" value="Default"/>

        <parm name="linear_security_level" value="Default"/>

        <parm name="picklist" value="Default"/>

        <parm name="aim_type" value="Default"/>

        <parm name="same_barcode_timeout" value="500"/>

        <parm name="different_barcode_timeout" value="500"/>

        <parm name="illumination_mode" value="Default"/>

        <parm name="lcd_mode" value="Default"/>

        <parm name="delay_to_low_power_mode" value="Default"/>

        <parm name="illumination_brightness" value="10"/>

        <parm name="inverse_1d_mode" value="Default"/>

        <parm name="1d_marginless_decode_effort_level" value="Default"/>

        <parm name="poor_quality_bcdecode_effort_level" value="Default"/>

        <parm name="viewfinder_mode" value="Default"/>

        </characteristic>

        <characteristic type="ScanParams">

        <parm name="code_id_type" value="Default"/>

        <parm name="volume_slider_type" value="Default"/>

        <parm name="decode_audio_feedback_uri" value=""/>

        <parm name="decode_haptic_feedback" value="Default"/>

        <parm name="bt_disconnect_on_exit" value="Default"/>

        <parm name="connection_idle_time" value="600"/>

        <parm name="establish_connection_time" value="45"/>

        <parm name="display_bt_address_barcode" value="Default"/>

        <parm name="good_decode_led_timer" value="75"/>

        <parm name="decoding_led_feedback" value="Default"/>

        </characteristic>

        </characteristic>

        <characteristic type="Intent" version="0.1">

        <parm name="emdk_name" value="dataCaptureIntent"/>

        <parm name="intent_output_enabled" value="true"/>

        <parm name="intent_action" value="com.example.johnfoley.myapplication.RECVR"/>

        <parm name="intent_category" value="android.intent.category.DEFAULT"/>

        <parm name="intent_delivery" value="0"/>

        <characteristic type="BasicDataFormatting">

        <parm name="bdf_enabled" value="true"/>

        <parm name="bdf_prefix" value=""/>

        <parm name="bdf_suffix" value=""/>

        <parm name="bdf_send_data" value="true"/>

        <parm name="bdf_send_hex" value="Default"/>

        <parm name="bdf_send_tab" value="Default"/>

        <parm name="bdf_send_enter" value="Default"/>

        </characteristic>

        </characteristic>

        <characteristic type="Keystroke" version="0.1">

        <parm name="emdk_name" value=""/>

        <parm name="ime_output_enabled" value="false"/>

        <parm name="keystroke_action_char" value="Default"/>

        <characteristic type="BasicDataFormatting">

        <parm name="bdf_enabled" value="Default"/>

        <parm name="bdf_prefix" value=""/>

        <parm name="bdf_suffix" value=""/>

        <parm name="bdf_send_data" value="Default"/>

        <parm name="bdf_send_hex" value="Default"/>

        <parm name="bdf_send_tab" value="Default"/>

        <parm name="bdf_send_enter" value="Default"/>

        </characteristic>

        </characteristic>

        </characteristic>

      </wap-provisioningdoc>

       

      End EMDKConfig.xml-----------------------------------------

        • Re: Enabling and disabling the scanner and msr
          Robert Galvin

          John,

           

          Does your application allow for having scanning and MSR being performed on different activities? You can use the Activity Selectorhttp://emdk.github.io/docs/3.1/#guide-profiles-profileactivityfeature to help automate the process. Have you also considered using the Barcode APIs as opposed to using Data Capture profiles?

          • Re: Enabling and disabling the scanner and msr
            Robert Galvin

            John

             

            Besides using Native Barcode API for Barcode and DataCapture Profile for MSR, you can also try this method, which is an intent based scheme for Datawedge:

             

            1.       Create four DataWedge profiles with four Scanner/MSR combinations (Do not set a application association to any of the profiles)

            2.       By using the SwitchToProfile API intent switch to the required profile. This way you do not have to modify the profiles and just switch to the required configuration by broadcasting a intent.

             

            Following is the extract from the API documentation on how to

             

            SwitchToProfile

             

            DESCRIPTION

            The SwitchToProfile API action can be used to switch to the specified profile.

            PROFILES RECAP

            DataWedge is based on profiles and plug-ins. A profile contains information on how DataWedge should behave with different applications.

            Profile information consists of:

            ·         Associated application

            ·         Input plug-in configurations

            ·         Output plug-in configurations

            ·         Process plug-in configurations

            DataWedge includes a default profile, Profile0, that is created automatically the first time DataWedge runs.

            Using profiles, each application can have a specific DataWedge configuration. For example, each user application can have a profile which outputs scanned data in the required format when that application comes to the foreground.DataWedge can be configured to process the same set of captured data differently based on the requirements of each application.

             

            Note

             

            A single profile may be associated with one or many activities/apps, however, given an acitivty, only one profile may be associated to it.

            USAGE SCENARIO

            Let’s say an application has two activities. ActivityA only requires EAN13 barcodes to be scanned. ActivityB only requires MSR card data. ProfileB is configured to only scan EAN13 barcodes and is left un-associated. ProfileM is configured to only accept MSR input and is left un-associated. When ActivityA launches it uses switchToProfile to activate ProfileB. Similarily, when ActivityB launches it uses switchToProfile to activate ProfileM.

            If another activity/app comes to the foreground, DataWedge auto profile switching will set the DataWedge profile accordingly either to the default profile or to an associated profile.

            When ActivityA (or ActivityB) comes back to the foreground it will use switchToProfile to reset the profile back to ProfileB (or ProfileM).

            FUNCTION PROTOTYPE

            Intent i = new Intent();
            i.setAction(ACTION);
            i.putExtra(EXTRA_DATA, "<profile name>");

            PARAMETERS

            ACTION:

            String "com.symbol.datawedge.api.ACTION_SWITCHTOPROFILE"

            EXTRA_DATA:

            String "com.symbol.datawedge.api.EXTRA_PROFILENAME"

            <profile name>:

            The profile name to switch to as a string (case-sensitive).

            RETURN VALUES

            None.

            Error and debug messages will be logged to the Android logging system which then can be viewed and filtered by the logcat command. You can use logcat from an ADB shell to view the log messages, e.g.

            $ adb logcat -s DWAPI

            Error messages will be logged for invalid actions, parameters and failures (e.g. profile not found or associated to an application).

            EXAMPLE

            // define action and data strings
            String switchToProfile = "com.symbol.datawedge.api.ACTION_SWITCHTOPROFILE";
            String extraData = "com.symbol.datawedge.api.EXTRA_PROFILENAME";
             
            public void onResume() {
                    super.onResume();
                    // create the intent
                    Intent I = new Intent();
                    // set the action to perform
                    i.setAction(switchToProfile);
                    // add additional info
                    i.putExtra(extraData, "myProfile");
                    // send the intent to DataWedge
                    context.this.sendBroadcast(i);
            }

            COMMENTS

            This API function will have no effect if the specified profile does not exist or if the specified profile is associated to an application.

            DataWedge has a one-to-one relationship between profiles and activities, i.e. only one profile can be associated to any given activity. When a profile is initially created, it is not associated to any application. Until this profile is associated to an activity it will never be activated. In this way it is possible to create multiple profiles that are un-associated.

            This API function allows you to switch to one such un-associated profile.

            For example, let’s say that ProfileA is one such un-associated profile and ProfileB is associated with activity B. Now, activity A is launched and uses this DataWedge API intent to switch to profileA. ProfileA will be active whilst activity A is in foreground. When another activity, say activity B, comes to the foreground DataWedge will automatically switch profile (to profileB which is associated to activity B for example). Then when activity A comes back to the foreground again, the app will need to use this DataWedge API intent to switch back to profileA. This would be done in the onResume method of activity A.

             

            Note

             

            Because DataWedge will automatically switch profile when your activity is paused, it is recommended that this API function be called from the onResume method of your activity.

            Note

            After switching to a profile, this un-associated profile does not get assigned to the application/activity and is available to be used in the future with a different app/activity.

             

            Note

            DataWedge automatic profile switching

            For backward compatibility, DataWedge’s automatic profile switching is not affected by the above API commands, and this also why the above API commands only work with un-associated profiles and apps.

            DataWedge auto profile switching works as follows…

            Every second…

            1.      Set newProfileId to the associated profile id of the current foreground activity

            2.      If no associated profile found then set newProfileId to the associated profile id of the current foreground app

            3.      if no associated profile found then set newProfileId to the current default profile (note: this may not be Profile0)

            4.      Check the newProfileId against the currentProfileId

            5.      If they are different then…

            a.       deactivate current profile

            b.      activate new profile (newProfileId)

            c.       set currentProfileId = newProfileId