Hi all,
we are developing a mobile application for Android and iOS and we have chosen the Xamarin.Forms platform to create our app in a cross-platform manner. This app shall use external functions provided to us as external library. Currently, this library is available for Android as native Android library (Android Library, written in Java and compiled as .aar file). The external library also includes a sample Android app written in Java as well in order to verify that the library is working and in order to demonstrate the library. The library plus sample app can be opened in Android Studio IDE and can be tested nicely. Soon, our partner will provide an iOS version of this library, probably as native iOS library.
Binding the library as described in https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-an-aar/ works well which means the imported namespace, classes and methods of the library are nicely accessible in our Xamarin project.
Now, we are facing the following problem: It is required that the App class (which is the application instance for the compiled Android app to which all activities refer to and which must be a sub-class of android.app.Application) must inherit 'MyApplication' which is part of the library. In other words, 'MyApplication' extends android.app.Application and implements some interface which is part of the library as well and 'App' (our Android application instance) must extend 'MyApplication'. Otherwise, the library functions do not properly work. But how to make this work in a Xamarin cross-platform application? In our Xamarin cross-platform project, there can be defined a custom application class inheriting from xamarin.forms.application but it is not possible to let this class inherit from 'MyApplication' because latter is Android-only but the cross-platform application class should be platform-independent of course. Otherwise, within the Android project of our solution there is a class MainActivity.cs which calls LoadApplication() to which I can pass a xamarin.forms.application object but how to pass my Android app class extending android.app.Application? Are xamarin.forms.application and android.app.Application somehow convertable? Also, within OnCreate() within the MainActivity.cs, it is possible to get the current application instance (which is in fact of type android.app.Application) but is it possible to set it?
Thank you all very much in advance for some inputs.