Data Capture using Intent using Profile Manager

A App Developer 2 years 11 months ago
8 4 0

Hi,
 
I have been trying to follow the sample tutorial for data capture using intent. The intent action always comes as android.intent.action.MAIN. I do not get the RECVR intent  action in the method handleDecodeData. I am using EMDK 6.3 and the device used is TC56.
Is there anything I could be missing here?
 
Your help would be very much appreciated.

Please register or login to post a reply

4 Replies

A App Developer

Thank you for responding! Please find below the EMDKConfig.xml. The delivery method was previously 'Send via startActivity' as per demo. I changed it to BroadcastIntent. But that does not help either.

Also, is there anything required to be done with the default DataWedge profile that comes with the device or anything else at all with respect to data wedge?

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

V Vedsatx Saddvv

My apologies it appears you're on part 2 of the intent tutorial, having the Delivery set to StartActivity is correct.

In your profile try disabling the keystroke output.

Also in you Manifest make sure you have the correct listed for your activity.

V Vedsatx Saddvv

Can you share your EMDKConfig.xml under /assets in your project?

Make sure you're changing the delivery method of your intent profile to Broadcast Intent.

A App Developer

I have added the EMDKConfig.xml and it is being moderated currently. Please find below the Java file being used. It is the similar to the sample.

I would like to know when handleDecodeData should be called. It is called once at first when the activity is launched. However, it is not called again when I scan a barcode. So, I think when I scan a barcode, the new intent is not being triggered.

package com.bozzutos.scanningtutorial;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.symbol.emdk.*;
import com.symbol.emdk.EMDKManager.EMDKListener;

public class MainActivity extends Activity implements EMDKListener{

   //Assign the profile name used in EMDKConfig.xml   private String profileName = "DataCaptureProfile";

   //Declare a variable to store ProfileManager object   private ProfileManager mProfileManager = null;

   //Declare a variable to store EMDKManager object   private EMDKManager emdkManager = null;

   //Declare a variable to store the textViewBarcode   private TextView textViewBarcode = 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);

   //Get the textViewBarcode   textViewBarcode = (TextView) findViewById(R.id.textViewBarcode);
//Check the return status of getEMDKManager   if(results.statusCode == EMDKResults.STATUS_CODE.FAILURE)
  {
   //Failed to create EMDKManager object   }

   //In case we have been launched by the DataWedge intent plug-in   Intent i = getIntent();
  handleDecodeData(i);
  }
   //We need to handle any incoming intents, so let override the onNewIntent method   @Override   public void onNewIntent(Intent i) {
  System.out.println("on new intent...."+i.getAction());
  handleDecodeData(i);

  }
   //This function is responsible for getting the data from the intent   private void handleDecodeData(Intent i)
  {
  System.out.println("----------------------------------------------------------------------------in handledecode data : "+i.getAction());
   //Check the intent action is for us   if (i.getAction().contentEquals("com.bozzutos.scanningtutorial.RECVR") ) {
   //Get the source of the data   String source = i.getStringExtra("com.motorolasolutions.emdk.datawedge.source");

//Check if the data has come from the Barcode scanner   if(source.equalsIgnoreCase("scanner"))
  {
   //Get the data from the intent   String data = i.getStringExtra("com.motorolasolutions.emdk.datawedge.data_string");
  System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  System.out.println("SCanned data : "+data);
//Check that we have received data   if(data != null && data.length() > 0)
  {
   //Display the data to the text view   textViewBarcode.setText("Data = " + data);
  }
  }
  }
  }
   @Override   public void onClosed() {
   // TODO Auto-generated method stub   }
   @Override   public void onOpened(EMDKManager emdkManager) {
   // TODO Auto-generated method stub   this.emdkManager = emdkManager;
//Get the ProfileManager object to process the profiles   mProfileManager = (ProfileManager) emdkManager.getInstance(EMDKManager.FEATURE_TYPE.PROFILE);
   if(mProfileManager != null)
  {
   try{

  String[] modifyData = new String[1];
  EMDKResults results = mProfileManager.processProfile(profileName, ProfileManager.PROFILE_FLAG.SET, modifyData);
   if(results.statusCode == EMDKResults.STATUS_CODE.FAILURE)
  {
  }
  }catch (Exception ex){
  ex.printStackTrace();
   // Handle any exception   }

  }
  }

   @Override   protected void onDestroy() {
   // TODO Auto-generated method stub   super.onDestroy();
   //Clean up the objects created by EMDK manager   emdkManager.release();
  }
}

CONTACT
Can’t find what you’re looking for?