When using Xamarin and Java Binding Projects the resulting Binding Project naturally follows the java coding style. I.e. expecting the use of anonymous classes (to implement simple callback interfaces) as parameters. Here is an example of the java code:
// Field
private Player mPlayer;
SDKClass.staticMethod(oneObject, anotherObject, new InitializationObserver() {
@Override
public void onInitialized(SomeClass someClass) {
// Calls mPlayer
}
@Override
public void OnError (Java.Lang.Throwable Error)
{
Console.WriteLine("Error in initialization: " + Error.Message);
}
}
The resulting C# code also expect an InitializationObserver
as the third parameter. However, since the SDK is closed and I am unable to change the implementation, the only way I can do this is by implementing the interface and its "override" methods in an inner class. This seems very unpractical to me.
In java I can access non-static members from the anonymous class (e.g. the field mPlayer), but afaik this is not possible in C#.
Is there another approach when creating Java Binding Projects in Xamarin that is allows for this? Is there a better way of dealing with the generated classes?
Thank you for helping out. Fred