xamarinxamarin-bindingxamarin-native

How to bind service from Java library in Xamarin Android Project


How to bind a service created in 3rd party library project in Xamarin Android project.??


Solution

  • You can refer to this article Binding a Java Library. In the Microsoft doc, first you can get the class from the .aar file.

    var ClassName = new Com.MyCompany.MyProject.MyclassName();
    

    Then use the bindService or other methods to use the Class.

    var Result =context.getApplicationContext.bindService(new Intent(context,typeof(ClassName)), new ServiceConnection(),Bind.AutoCreate);