4 Replies Latest reply on Aug 18, 2016 4:59 AM by Petr Brant

    Barcode API - very slow

    Petr Brant

      Good morning,

       

      we have Android Xamarin application with Barcode Scanner API. On every Activity we have InitScanner method OnResume event and DeinitScanner method on OnPause event.

       

      public void InitScanner(bool enableScannerOnStartup)
      {
          if (emdkManager != null)
          {
              if (barcodeManager == null)
              {
                  try
                  {
                      barcodeManager = (BarcodeManager) emdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Barcode);
                      scanner = barcodeManager.GetDevice(BarcodeManager.DeviceIdentifier.Default);
                      if (scanner != null)
                      {
                          scanner.Data += scanner_Data;
                          scanner.Enable();
                      }
                  }
                  catch (ScannerException e)
                  {
                      //LOG
                  }
                  catch (Exception e)
                  {
                      //LOG
                  }
              }
          }
      }
      
      public void DeinitScanner()
      {
          if (emdkManager != null)
          {
              if (scanner != null)
              {
                  try
                  {
                      scanner.Data -= scanner_Data;
                      scanner.Status -= scanner_Status;
                      scanner.Disable();
                  }
                  catch (ScannerException e)
                  {
                      //LOG
                  }
              }
              if (barcodeManager != null)
              {
                  emdkManager.Release(EMDKManager.FEATURE_TYPE.Barcode);
              }
              barcodeManager = null;
              scanner = null;
          }
      }
      

       

       

      InitScanner and DeinitScanner is called for every Activity. We have problem with speed (Init takes aproximately 4 seconds - on every StartActivity). What is the best solution how to speed up application (BarcodeAPI, DataWedge profile, create scanner singleton)?

       

      Thank you for advice.