title: AndroidJavaClass and AndroidJavaObject for C# .Net Framework
body: <p>I have code in Unity that calls a function programmed in Java for Android using AndroidJavaClass and AndroidJavaObject and I would like to pass this code to a dll in C# .Net but I can't find an easy way to call Java functions using C# .Net since the AndroidJavaObject and AndroidJavaClass classes are exclusive to the Unity dll, here is an example of my code:</p>
  <p>Java (Android):</p>
  <pre><code>public class DeviceManager {
      public interface DeviceListener {
          void DoSomething();
      }
  
      private DeviceListener deviceListener;
  
      public DeviceManager(DeviceListener deviceListener){
          this.deviceListener = deviceListener;
      }
      
      public String[] getSomeData(){
          return new String[]{};
      }
  }
  </code></pre>
  <p>C# (Unity):</p>
  <pre><code>public class DeviceListener : AndroidJavaProxy
  {
      DeviceManager deviceManager;
  
      public DeviceListener(DeviceManager manager) : base(&quot;com.myapp.DeviceManager$DeviceListener&quot;)
      {
          this.deviceManager = manager;
      }
  
      public void DoSomething();
  }
  
  public class DeviceManager
  {
      private AndroidJavaObject jo;
  
      public DeviceManager(){
           jo = new AndroidJavaObject(&quot;com.myapp.DeviceManager&quot;, new DeviceListener(this));
      }
  
      public string[] GetData(){
          AndroidJavaObject returnedData = jo.Call&lt;AndroidJavaObject&gt;(&quot;getSomeData&quot;);
          return AndroidJNIHelper.ConvertFromJNIArray&lt;string[]&gt;(returnedData.GetRawObject());
      }
  }
  </code></pre>
  <p>What is the best way to do that example in C# .Net instead of Unity?</p>
  <p><strong>EDIT:</strong> my main question is related to know how to get objects and call functions from an .aar file in .NET Framework inside a dll C# file for Unity</p>
  <p><strong>EDIT 2:</strong> I found some information about Xamarin, maybe that is what I am looking for?: <a href="https://github.com/xamarin/monodroid-samples/tree/master/JavaIntegration/AarBinding" rel="nofollow noreferrer">https://github.com/xamarin/monodroid-samples/tree/master/JavaIntegration/AarBinding</a> But even though I could link an .aar file to a dll in C# that doesn't quite answer my question in the best way to create a code that works the same as the example described above</p>
  <p><strong>EDIT 3:</strong> Currently, to solve this problem, I am using the UnityEngine .dll in my Visual Studio project but I want to generate a .dll for use in other graphics engines so I would like to be able to find a different solution than using Unity's own .dll for solve this problem, hence I mentioned Xamarin since it is a good way to communicate .Net Framework with Android (Java) but I have not found any example that uses it outside of a mobile application created in Visual Studio since in my case I would need to obtain objects and call functions from the .aar file</p>