IntPtr problem

we are developing our first app on motorola mc9200 (android) with visual studio, and we start explore the functionality with EMDK SDK, we looked examples and is all quite ok, but now we need to move the IEMDKListener interface from the main activity to one specialized class, we have implemented the interface IEMDKListener on class,

 

  public class BarCode : IDisposable, EMDKManager.IEMDKListener

....

 

but requiere IntPtr Handle property, how to implement it?

 

        public IntPtr Handle

        {

            get

            {

                return ??;

            }

        }

 

there are example of this situation?

 

another question, is possible enable/disable the led on device? we need to signal particular situation.

 

thanks

Anonymous (not verified)
Hello Giovanni,     As of now

Hello Giovanni,

     As of now, we have no EMDK for Xamarin examples that separate the IEMDKListener from the Activity. To help understand what you are trying to accomplish, could you included a sample of your code? I'm not sure I understand what you need to do.

As for the LED control, you would need to use the standard Android Notification APIs​ ( or the xamarin.android equivalent ) not the EMDK.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Giovanni Ferrari
when i specify the

when i specify the IEMDKListener interface (to my class) i must add the

EMDKManager.IEMDKListener.OnClosed() & EMDKManager.IEMDKListener.OnOpened(),

but, visual studio signal error and specify that need also 'Handle' interface member (as you can see on the image)

i think that Handle must point to EMDKManager.IEMDKListener.OnOpened() interface function, so when the IEMDKListener

finish preparing can call OnOpened().

the problem for me is to know the correct way to do this

hope this time explained better!

zebra.png

extract of the class:

 

public class BarCode : EMDKManager.IEMDKListener

    {

        private Scanner scanner = null;

        private EMDKManager _emdkManager = null;

        private BarcodeManager barcodeManager = null;

  public EMDKResults PrepareDevice(bool enableScanner)

        {

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

            _enableScanner = enableScanner;

            return results;

        }

        public BarCode()

        {

        }

        public IntPtr Handle

        {

            get

            {

                LogHandler counter = new LogHandler(OnOpened);

                //// Delegate untypedManagedMethod = (Delegate)counter;

                IntPtr nativeThunk = Marshal.GetFunctionPointerForDelegate(counter);

  return nativeThunk;

            }

        }

         [UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall, SetLastError = true)]

        public delegate void LogHandler(EMDKManager emdkManager);

        void EMDKManager.IEMDKListener.OnClosed()

        {

            ReleaseResource();

        }

        static void OnOpened(EMDKManager emdkManager)

        {

            string s = "";

        }

        void EMDKManager.IEMDKListener.OnOpened(EMDKManager emdkManager)

        {

            _emdkManager = emdkManager;

  // .......

        }

  }

we make this class becouse we use EMDK on 2 different part of the program, so, to make things 'standard' we prefer make this class, is more difficult mantain the same code in 2 different part (maybe in the future become 3..)

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Giovanni Ferrari
noone can help?

noone can help?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Giovanni, Sorry for the delay

Giovanni, Sorry for the delay, but as of now we don't have any supported examples of using the EMDK for Xamarin in the manor you are using it. I am still looking into this and will reply as soon as I possible.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Giovanni,     It looks

Hi Giovanni,

     It looks like you will need to subclass Java.Lang.Object.  If you have implemented a dispose() method in your class, remove it because it will hide the dispose method in Java.Lang.Object.

class EMDK : Java.Lang.Object,IDisposable, EMDKManager.IEMDKListener

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Charitha Mallaw...
Hi Giovanni,Sorry for taking

Hi Giovanni,

Sorry for taking long and hope this resolves your issue. Attached the modified sample. Basically you need to extend the class from Java.Lang.Object and remove Dispose and Handle functions generated from interface as it is taken from Object.

class Barcode: Java.Lang.Object, EMDKManager.IEMDKListener

This is a generic Xamarin usage query and explained in Xamarin docs: Android Callable Wrappers - Xamarin

Please get back to us if this is not resolving your issue.

Thanks,

Charith.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Alexander Friesen
It doen't work also.Unhandled

It doen't work also.

Unhandled Exception: Java.Lang.ClassNotFoundException: <Timeout exceeded getting exception details>

Exactly on calling public EventListener(MainActivity mainActivity)

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Giovanni Ferrari
thanks for the example, we

thanks for the example, we start change the class..

about the leds on mc9200, i not mean flash led or similar (like on regular telephone), the mc9200 have led (orange) for battery (and flash when charging), also red led (3) that signal when barcode is not decoded and 3 leds (green) that indicate barcode recognized, i ask if is possible control this leds

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments