Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin - How to adapt Java Event and Listeners to C⧣

OdShadOdShad Member ✭✭

so recently I had to work with an Android SDK that was built in Java, so I created a javabinding project and got the .dll file that I added to my Xamarin project later on as a reference.

Now Im just trying to follow the "How to use" pdf that comes with it but Im kinda stuck in the part where I should register the EventListener. I know that there is no event keyword in Java. In Java you are essentially faking events and event handling by using a standard set of naming conventions.

And on Xamarin documentation I found that :

The Xamarin.Android Binding Generator will change some Java idioms and patterns to correspond to .NET patterns. The following list describes how Java is mapped to C#/.NET:

  • Setter/Getter methods in Java are Properties in .NET.

  • Fields in Java are Properties in .NET.

  • Listeners/Listener Interfaces in Java are Events in .NET. The parameters of methods in the callback interfaces will be represented by an EventArgs subclass.

  • A Static Nested class in Java is a Nested class in .NET.

Here is the Java work in the pdf that I should convert :

the confusion that I have is on the "printer.setReceiveEventListener(this);"
"this" is an interface called IReceiverListener

Can you please help me do things right ?


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Can you post the project on github?

    Something like printer.Receive +=….???

Sign In or Register to comment.