EMDK cannot restart after emdk.release()

Hi guys,

I am a developer working with emdk 3.1 on TC-75 android 4.4.3. The issue I have is that I have two activity A and B. When click button on A, it pop out B. Both activity implement EMDK interfaces. In A's on Stop, I call emdkManager.release() so I can use emdk in B. Everything works fine on B. But when I close B and release B's emdkManager so that I return to A, the emdk service on A will never work again. In A's onStart, I call emdkResult but it seems it does not open the emdk service.

 

this is the some pieces of code:

Activity A:

@Override
protected void onStop() {

   super.onStop();

  Log.i("ScannerActivity", "OnStop");

  deInitScanner();

   if (emdkManager != null) {

   emdkManager.release();

  }

}

 

@Override
protected void onStart() {

   super.onStart();

  Log.i("ScannerActivity", "OnStart");

  EMDKResults results = EMDKManager.getEMDKManager(getApplicationContext(), this);

   if (results.statusCode != EMDKResults.STATUS_CODE.SUCCESS) {

   txtStatus.setText("Status: " + "EMDKManager object request failed!");

  }

 

   new AsyncStatusUpdate().execute(statusString);

  startScan();

   new AsyncUiUpdate().execute(false);

 

}

 

 

public void deInitScanner() {

 

   if (scanner != null) {

   try {

 

   scanner.cancelRead();

   scanner.removeDataListener(this);

   scanner.removeStatusListener(this);

   scanner.disable();

   scanner = null;

 

  } catch (ScannerException e) {

 

   txtStatus.setText("deInitScanner-Status: " + e.getMessage());

   // getActionBar().setSubtitle("Status: " + e.getMessage());
   }

 

   // scanner = null;
   }

}

 

This is all the logs I have when I close the activity B and back to A.

05-23 09:26:04.977 31690-31690/com.monsanto.scanmaster.invetory.envDev D/com.symbol.emdk.EMDKServiceConnection: The EMDK Service will be connected soon (asynchronus call)!

05-23 09:26:04.987 31690-31690/com.monsanto.scanmaster.invetory.envDev D/com.symbol.emdk.EMDKServiceConnection: The EMDK Service is now connected!

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: start - getNumberOfScanners

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: end - getNumberOfScanners

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: start - getScannerInfo

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: end - getScannerInfo

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: start - getScannerInfo

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: end - getScannerInfo

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: start - getScannerInfo

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: end - getScannerInfo

05-23 09:26:05.808 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: SvcScanEventCallback::barcodeManager

05-23 09:26:05.818 5107-5121/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: SvcScanner::open

05-23 09:26:05.818 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: Scanner.open start: scannerIndex: 1

05-23 09:26:05.898 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: Scanner.open end

05-23 09:26:05.908 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - registerScanEventCallback

05-23 09:26:05.908 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - registerScanEventCallback

05-23 09:26:05.908 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - enable

05-23 09:26:06.248 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - enable

05-23 09:26:06.248 5107-5122/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerConfig: start - getCurrentParameters

05-23 09:26:06.248 5107-5122/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerConfig: end - getCurrentParameters

05-23 09:26:06.248 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_ENABLED

05-23 09:26:06.258 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: mScanner==null

05-23 09:26:06.258 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_ENABLED

05-23 09:26:06.258 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug. =========SVC SS MANAGER======== PID: 5107

05-23 09:26:06.258 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 2,005.30KB of 2,460.00KB (294.70KB free)

05-23 09:26:06.258 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 1.96MB of 2.40MB (0.29MB free)

05-23 09:26:06.258 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12.00MB of 96.00MB (1.00MB free)

05-23 09:26:06.258 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12,760.00KB of 98,304.00KB (1,124.00KB free)

05-23 09:26:06.258 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...Triggering: IDLE

05-23 09:26:06.268 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: start - getScannerInfo

05-23 09:26:06.268 5107-8323/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerUtils: end - getScannerInfo

05-23 09:26:06.268 5107-5121/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - getScanStatus

05-23 09:26:06.268 5107-5121/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerConfigHelper: start - setParameters

05-23 09:26:06.278 5107-5121/? D/com.symbol.emdk.emdkservice.barcode.SvcScannerConfigHelper: end - setParameters

05-23 09:26:06.368 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - startScanning

05-23 09:26:06.368 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - startScanning

05-23 09:26:06.368 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_WAITFORTRIGGER

05-23 09:26:06.368 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: mScanner==null

05-23 09:26:06.368 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_WAITFORTRIGGER

05-23 09:26:06.378 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug. =========SVC SS MANAGER======== PID: 5107

05-23 09:26:06.378 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 2,007.92KB of 2,460.00KB (292.08KB free)

05-23 09:26:06.378 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 1.96MB of 2.40MB (0.29MB free)

05-23 09:26:06.378 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12.00MB of 96.00MB (1.00MB free)

05-23 09:26:06.378 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12,760.00KB of 98,304.00KB (1,076.00KB free)

05-23 09:26:06.378 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...Triggering: WAITING

05-23 09:26:06.979 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err: com.symbol.emdk.barcode.ScannerException: Failure

05-23 09:26:06.979 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.cancelRead(Scanner.java:567)

05-23 09:26:06.979 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.removeDataListener(Scanner.java:603)

05-23 09:26:07.029 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.unRegisterDataNotification(Scanner.java:739)

05-23 09:26:07.029 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.removeDataListener(Scanner.java:607)

05-23 09:26:07.039 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.unRegisterStatusNotification(Scanner.java:773)

05-23 09:26:07.039 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.removeStatusListener(Scanner.java:676)

05-23 09:26:07.049 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err: com.symbol.emdk.barcode.ScannerException: Failure

05-23 09:26:07.049 31690-31690/com.monsanto.scanmaster.invetory.envDev W/System.err:     at com.symbol.emdk.barcode.Scanner.disable(Scanner.java:405)

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - getScanStatus

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - getScanStatus

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - stopScanning

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - stopScanning

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_ENABLED

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: mScanner==null

05-23 09:26:07.049 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_ENABLED

05-23 09:26:07.059 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug. =========SVC SS MANAGER======== PID: 5107

05-23 09:26:07.059 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 2,010.80KB of 2,460.00KB (289.20KB free)

05-23 09:26:07.059 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 1.96MB of 2.40MB (0.28MB free)

05-23 09:26:07.059 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12.00MB of 96.00MB (1.00MB free)

05-23 09:26:07.059 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12,760.00KB of 98,304.00KB (1,066.00KB free)

05-23 09:26:07.059 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...Triggering: IDLE

05-23 09:26:07.059 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - getScanStatus

05-23 09:26:07.059 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - disable

05-23 09:26:07.079 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - disable

05-23 09:26:07.079 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_IDLE

05-23 09:26:07.079 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: mScanner==null

05-23 09:26:07.079 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...STATUS: SCAN_STATUS_IDLE

05-23 09:26:07.089 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug. =========SVC SS MANAGER======== PID: 5107

05-23 09:26:07.089 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 2,004.13KB of 2,460.00KB (295.87KB free)

05-23 09:26:07.089 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.heap native: allocated 1.96MB of 2.40MB (0.29MB free)

05-23 09:26:07.089 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12.00MB of 96.00MB (1.00MB free)

05-23 09:26:07.089 5107-32295/? D/tag: com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback_HL > debug.memory: allocated: 12,760.00KB of 98,304.00KB (1,055.00KB free)

05-23 09:26:07.089 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanEventCallback: onScanEvent...Triggering: DISABLED

05-23 09:26:07.089 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: start - release

05-23 09:26:07.089 5107-32295/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: end - release

05-23 09:26:07.089 5107-5121/? D/com.symbol.emdk.emdkservice.barcode.SvcScanner: set scanner object to null: sfScannerObj

05-23 09:26:07.139 31690-31690/com.monsanto.scanmaster.invetory.envDev D/com.symbol.emdk.EMDKServiceConnection: The connection to the EMDK Service was closed.!

 

 

 

My question is, when I back to A, how to make emdk service work again? Everything in activity B works fine. When I close B and back A, scanner.read() will give me the error. It seems emdk service has been closed.