onNewIntent not called for TC56.

// Expert user has replied.
P Prakhar Srivastava 3 years 6 months ago
3 1 0

I am trying to get the Scanner value via intent filter.
First of all, I have a BaseActivity which is extended by Every other activity, I tried to implement it there, but all I could manage was get the Scanned Value in the EditText.
onNewIntent() was not called at all.
 
Now I have exactly same code in two Activities. I get the result in one of the activities and not in other.
Following is the code that I wrote following the documentation:
 
private String profileName = "PackageScan";private ProfileManager mProfileManager = null;private EMDKManager emdkManager = null;
 
@Override   protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);   initAddlayout(R.layout.activity_scanner);   EMDKResults results = EMDKManager.getEMDKManager(getApplicationContext(), this);  if(results.statusCode == EMDKResults.STATUS_CODE.FAILURE)
  {
   //Failed to create EMDKManager objec   }
 
//CRASHES IF I UN-COMMENT THIS
   /* Intent i = getIntent();  handleDecodeData(i);*/   }
   @Override   protected void onDestroy() {
   emdkManager.release();  super.onDestroy();   }
   @Override   public void onOpened(EMDKManager emdkManager) {
   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];   //Call processPrfoile with profile name and SET flag to create the profile. The modifyData can be null.   EMDKResults results = mProfileManager.processProfile(profileName, ProfileManager.PROFILE_FLAG.SET, modifyData);  if(results.statusCode == EMDKResults.STATUS_CODE.FAILURE)
  {
   //Failed to set profile   }
  }catch (Exception ex){
   // Handle any exception   }
 
  }
  }
 
   @Override   public void onClosed() {
 
  }
 
   @Override   public void onNewIntent(Intent i) {
  handleDecodeData(i);   }
   private void handleDecodeData(Intent i) {
   if (i.getAction().contentEquals("app.iwiz.mypack.RECVR")) {
  String source = i.getStringExtra("com.motorolasolutions.emdk.datawedge.source");//Check if the data has come from the Barcode scanner   if (source.equalsIgnoreCase("scanner")) {
  String data = i.getStringExtra("com.motorolasolutions.emdk.datawedge.data_string");//Check that we have received data   if (data != null && data.length() > 0) {
  }
  }
  }
  }
 
 
The Same Code is written in ScannerActivity as well as TrackingListActivity .
 
When I scan while I am on ScannerActiivty, I immediately get two options to complete the request. One takes me to TrackingListActivity and other brings me to onNewIntent in same ScannerActivity .
I Understand this behavious is because I am using same Intent-filter and even same EMDK - Profile.
While on the other hand, when I scan while I am in TrackingListActivity , the onNewIntent doesn't get called. Neither do I get the option to complete request. I get the scanned value in EditText though.
 
I can't understand how the Context works overall.
I have 7-8  activities where I have to scan, so I want to get the scanned value to me in the BaseActivity itself.

Please Register or Login to post a reply

1 Replies

P Pietro Francesco Maggi

DataWedge profiles includes a reference to the package name and the activity (1 or multiple or all using "*") where the profile needs to be activated.

Can you please send a copy of the EMDKConfig.xml file you're using to setup the profile?

~Pietro

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