启用扫描仪引发异常Zebra EMDK Android

时间:2019-04-11 15:22:44

标签: android zebra

在适用于Zebra MC330M的应用程序中,我使用EMDK:Zebra Technologies Corp:EMDK APIs:26

我有一个实现监听器的活动,并且我重写了onOpened函数:

@Override
public void onOpened(EMDKManager emdkManager) {

    this.emdkManager = emdkManager;
    try {

       initializeScanner();
     } catch (ScannerException e) {

        Log.e("ON_OPENED", e.getMessage());
        e.printStackTrace();
     }

}

正如文档在链接中所述:Basic Scanning Tutorial using Barcode API - Zebra Technologies Techdocs

我放入了initializeScanner函数:

if (scanner == null) {

   // Get the Barcode Manager object
   barcodeManager = (BarcodeManager) emdkManager.getInstance(FEATURE_TYPE.BARCODE);
   // Add connection listener
   if (barcodeManager != null) {
      barcodeManager.addConnectionListener(this);
   }

   // Get default scanner defined on the device
   scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);
   // Add data and status listeners
   scanner.addDataListener(this);
   scanner.addStatusListener(this);
   // Hard trigger. When this mode is set, the user has to manually
  // press the trigger on the device after issuing the read call.
   scanner.triggerType = TriggerType.HARD;
   // Enable the scanner
   scanner.enable();
   startRead = true;

 }

但是当调用scanner.enable()时会抛出

  

ScannerException

消息异常:

  

“失败”

但是,当我尝试编译我的应用并在设备处于待机模式或设备长时间处于待机状态时启动时,似乎错误仅在调试模式下显示。

其他人有这个问题吗?

0 个答案:

没有答案