gpt4 book ai didi

xamarin - Xamarin 的 EMDK

转载 作者:行者123 更新时间:2023-12-02 22:02:42 25 4
gpt4 key购买 nike

我在 Xamarain.Android 应用程序中使用适用于 xamarin 的 EMDK。我收到此错误:

Unable to activate instance of type Symbol.XamarinEMDK.Barcode.Scanner+IStatusListenerImplementor from native handle 0x1d200001 (key_handle 0x426eae90).

此错误是随机发生的。

在下面查找详细日志。请帮忙解决这个问题

System.NotSupportedException: Unable to activate instance of type Symbol.XamarinEMDK.Barcode.Scanner+IStatusListenerImplementor from native handle 0x1d200001 (key_handle 0x41b8ad20). ---> System.MissingMethodException: No constructor found for Symbol.XamarinEMDK.Barcode.Scanner+IStatusListenerImplementor::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
at Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
at --- End of managed Java.Lang.Error stack trace ---
at java.lang.Error: Java callstack:
at at mono.com.symbol.emdk.barcode.Scanner_StatusListenerImplementor.n_onStatus(Native Method)
at at mono.com.symbol.emdk.barcode.Scanner_StatusListenerImplementor.onStatus(Scanner_StatusListenerImplementor.java:30)
at at com.symbol.emdk.barcode.StatusCallbackInternal$StatusCallbackThread.run(StatusCallbackInternal.java:73)
at --- End of managed Java.Lang.Error stack trace ---
at java.lang.Error: Java callstack:
at at mono.com.symbol.emdk.barcode.Scanner_StatusListenerImplementor.n_onStatus(Native Method)
at at mono.com.symbol.emdk.barcode.Scanner_StatusListenerImplementor.onStatus(Scanner_StatusListenerImplementor.java:30)
at at com.symbol.emdk.barcode.StatusCallbackInternal$StatusCallbackThread.run(StatusCallbackInternal.java:73)
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) [0x00058] in <filename unknown>:0
at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x00138] in <filename unknown>:0
--- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x001b0] in <filename unknown>:0
at Java.Lang.Object.GetObject (IntPtr handle, JniHandleOwnership transfer, System.Type type) [0x000e5] in <filename unknown>:0
at Java.Lang.Object._GetObject[T] (IntPtr handle, JniHandleOwnership transfer) [0x0001a] in <filename unknown>:0
at Java.Lang.Object.GetObject[T] (IntPtr handle, JniHandleOwnership transfer) [0x00000] in <filename unknown>:0
at Java.Lang.Object.GetObject[T] (IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer) [0x00006] in <filename unknown>:0
at Symbol.XamarinEMDK.Barcode.Scanner+IStatusListenerInvoker.n_OnStatus_Lcom_symbol_emdk_barcode_StatusData_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) [0x00000] in <filename unknown>:0
at at (wrapper dynamic-method) System.Object:043283ed-110f-43b7-811b-51b1dfa39e65 (intptr,intptr,intptr)

最佳答案

只是添加这个以防将来有人可能偶然发现它

不确定为什么会收到该错误,但这里有一个代码示例,无需添加 IStatusListenerImplementor 接口(interface)的实现即可工作。

private void SetupEmdkBarcodeScanner
{
var emdkBarcodeManager = (Symbol.XamarinEMDK.Barcode.BarcodeManager)emdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Barcode);
var emdkBarcodeScanner = emdkBarcodeManager.GetDevice(BarcodeManager.DeviceIdentifier.Default);
if(emdkBarcodeScanner.IsReadPending)
{
emdkBarcodeScanner.CancelRead();
}
emdkBarcodeScanner.Data += HandleReadEvent;
emdkBarcodeScanner.Status += HandleStatusEvent;
}

private void HandleStatusEvent(object sender, Scanner.StatusEventArgs e)
{
if (e.P0.State != StatusData.ScannerStates.Idle)
{
return;
}

lock (concurrentReadsLock)
{
Thread.Sleep(100);

if (scanner.IsReadPending)
{
return;
}

emdkBarcodeScanner.Read();
}
}

private void HandleReadEvent(object sender, Scanner.DataEventArgs e)
{
if (e.P0.Result != ScannerResults.Success)
{
return
}

foreach (ScanDataCollection.ScanData data in e.P0.GetScanData())
{
string aimBarcodeData = data.Data; //here is your scanned barcode (e.g.: "]E00123456789123"
//... your barcode processing code goes here //
}
}

另外,不要忘记最后处理:

emdkBarcodeScanner.CancelRead();
emdkBarcodeScanner.Disable();
//.. unsubscribe the event handlers
emdkBarcodeScanner.Dispose();
//...and finally release the EMDK to remove your application's exclusive access.
emdkBarcodeManager.Release(EMDKManager.FEATURE_TYPE.Barcode);

关于xamarin - Xamarin 的 EMDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39688568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com