2 Replies Latest reply on Oct 14, 2016 2:15 PM by Jon-Luke West

    Scanner Does Not Turn Off EMDK 5

    Jon-Luke West

      Developing an application for Android MC92KK with EMDK 5.

       

      After initializing the scanner in a Fragment and then completely destroying the parent Activity, but not closing the application because I am now in a different Activity without scanning, the scanner never turns off.  It seems to be stuck in a continuous scan mode somehow.

       

      if (emdkManager != null) {    // Clean up the objects created by EMDK manager    if (scanner != null) {    try {    //scanner.cancelRead();    scanner.removeDataListener(this);    scanner.removeStatusListener(this);    scanner.disable();     } catch (ScannerException e) {   e.printStackTrace();    }   }    emdkManager.release();    emdkManager = null; }

       

       

      I have gone as far as the code above in the onDestroy() for the fragment, but nothing will get the scanner to not turn on when I press the trigger except for completely closing the application.  The callbacks do not fire when I am on a different Fragment or Activity; so it doesn't seem to negatively impact the function of the application at this time.  I know this is going to be reported as a bug as soon as I hand it over to the User Acceptance Testing team though.  Am I missing something painfully obvious?

       

      EDIT Here are a couple of examples of application states:

       

      Example 1

       

      Application Starts -> Activity 1 Starts -> Activity 2 Starts -> Activity 3 Starts -> Activity 3 Loads Fragment 1 -> Fragment 1 Initializes Scanning ->  Activity 3 Loads Fragment 2 on top of Fragment 1 (Fragment 1's view is destroyed and I disable scanning with the above code) -> Scanner will turn on when the trigger is pressed from Fragment 2

       

      Example 2

      Application Starts -> Activity 1 Starts -> Activity 2 Starts -> Activity 3 Starts -> Activity 3 Loads Fragment 1 -> Fragment 1 Initializes Scanning -> Destroy Activity 3 and Fragment 1 (thus disabling scanning) -> Scanner will turn on when the trigger is pressed from Activity 2 -> Destroy Activity 2 -> Scanner will turn on when the trigger is pressed from Activity 1 -> Close application -> Scanner is disabled

       

       

      Thank you in advance for your help.

       

      Added some more clarification for where I am in the application