Passing Java object to and from C#

The AndroidJavaObject.Call generic has samples with string, bool and int return values, but can it be used to get back another java object?

I’d similarly like to know whether I can pass in a AndroidJavaObject into a AndroidJavaObject.Call call

Yes, the AndroidJavaObject can be a return or a method call. The only downside is that you, as the developer, have to know exactly what the return value is in order to use it properly.

The best way to use it is something like this:

AndroidJavaObject ajObject;
//some methods to set the object that you want to call the method on
AndroidJavaObject returnObj = ajObject.Call<AndroidJavaObject>("method name", "method arguments");

To get a return of a complex object from a static function you do something similar:

AndroidJavaClass ajClass = new AndroidJavaClass("com.example.package.NameOfClass");

AndroidJavaObject ajObject = ajClass.CallStatic<AndroidJavaObject>("method name", "method arguments");

Basically the lesson here is that you can get any return type you want from a call to an Android method by using the <“return type”> operator.

For passing the AndroidJavaObject as a parameter to a method, you just use it like any other simple type parameter. Just be sure that the type of the AndroidJavaObject that you are sending is what is expected by the Java method, otherwise it will not be called.