Search code examples
c#androidxamarin.androidmotorola-emdk

Motorola/Zebra mobile computer MC67 barcode scanning with Xamarin EMDK


I had already created an Android app to run on the MC67NA which previously was only shipped with Jelly Bean. Because the EMDK only supported KitKat and above, I had to do all barcode scanning via DataWedge. However, now that KitKat has been released and I now have a device running KitKat, I am modifying the app to use the EMDK instead of DataWedge. My question is, while I see all the samples provided and they do help get started, they are also geared towards a single layout/Activity application. My existing application has a main Activity which serves as a container for fragments and a view pager. I need to do scanning on several of the fragments when they are the active page in the view pager. The DataWedge made this easy because I didn't have to worry about any of that, it would just scan to the field which had focus.

All that said, what is the best way to implement the EMDK barcode scanner for this setup? I know many people are against a singleton class, but I was thinking about going down this road. Create a singleton to implement the scanner when the app starts up. From each fragment, I could then get the instance to the scanner class and use it. Can anybody give me some advice on this? I also don't know how exactly to also register the event handlers in the singleton (assuming this is the best method) and then have those events fire on the fragments.

I do want to get away from DataWedge and integrate the EMDK for various reasons.

Last, on a related note, I have started to code this approach and am getting an exception on this line:

EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this);  

The exception states:

Java.Lang.ClassNotFoundException: Didn't find class "com.symbol.emdk.EMDKManager" on path: DexPathList[[zip file "/data/app/PocketPacTracAndroid.PocketPacTracAndroid-2.apk"],nativeLibraryDirectories=[/data/app-lib/PocketPacTracAndroid.PocketPacTracAndroid-2, /vendor/lib, /system/lib]]

This happens even though I have included the reference:

enter image description here

Thanks in advance!

Mike


Solution

  • All, for the benefit of anybody else that may run into this issue, I found that simply including the reference dll is not enough for this. You also need to add the reference and permissions into your manifest. So, if you get this error, make sure you have these two lines in your manifest.

    1. Just below the "uses-sdk" tags

    <uses-permission android:name="com.symbol.emdk.permission.EMDK" />

    1. Inside of the "application" tags

    <uses-library android:name="com.symbol.emdk" />