App crashes when barcode manager is initialized


Dear ,
            I have the following MainActivity class and the app crashes as soon as i call the initializescanner method.All i wanted to do is start the scanner as soon as the app starts.

public class MainActivity implements EMDKListener  {
private BarcodeManager barcodeManager = null;   private Scanner scanner = null;
   private EMDKManager emdkManager = null;

@Overrideprotected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);   setContentView(R.layout.activity_main);
       EMDKResults results = EMDKManager.getEMDKManager(getApplicationContext(), this);        if (results.statusCode != EMDKResults.STATUS_CODE.SUCCESS) {
        //Failed to request the EMDKManager    }
@Override   public void onOpened(EMDKManager emdkManager) {
   this.emdkManager = emdkManager;   try {
   // Call this method to enable Scanner and its listeners   initializeScanner();   } catch (ScannerException e) {
  e.printStackTrace();   }

//The EMDK Manager is ready and now you can call other EMDK APIs.   }

private void initializeScanner() throws ScannerException {
   if (scanner == null) {
   barcodeManager = (BarcodeManager) this.emdkManager                              // the app crashes here   .getInstance(EMDKManager.FEATURE_TYPE.BARCODE);
   scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);   scanner.triggerType = Scanner.TriggerType.HARD;   scanner.enable();;   }

   @Override   public void onClosed() {
   /* EMDKManager is closed abruptly. Call EmdkManager.release() to free the resources used by the current EMDK instance. */   if (emdkManager != null) {
   emdkManager.release();   emdkManager = null;   }

   @Override   public void onDestroy(){
   super.onDestroy();   if (emdkManager != null) {
   emdkManager.release();   emdkManager = null;   }


Submitted by Anbu Selvan Joh... on May 04, 2019 Permalink

Could it be the problem of not configuring the Device Runtime Deployment.I am using a TC70 device with Android 5.0 version how to configure the runtime deployment for this.

Submitted by Anbu Selvan Joh... on May 04, 2019 Permalink

Hi Darryn,
               Thanks for the quick response.Yes i tried those barcode sample api.And then i moved on to create new project to use the same code that is used in sample barcode api.
The device which i run is TC70 device.