How to call a Android native class with implements from unity ?

Hi ,

How to call a native android method from Unity ?

native method :

public void sharePhoto(final String textPath, final String imagePath)


From Unity am calling like :

testClass.Call("sharePhoto","hai Sir","");

Result :

am not getting any error. but unable to enter into the method.

How to call ?

I think the problem is that testClass is an AndroidJavaClass - that is, it refers to the class itself, not to an instance of the class. That makes it good for calling static methods, but not non-static ones.

You need to create an instance instead, using AndroidJavaObject and issue the Call method on that, using the same syntax you’re using now.

AndroidJavaObject testObject = new AndroidJavaObject(className, constructorArg1, constructorArg2, ...);
testObject.Call(methodName, methodArg1, methodArg2, ...);

The first line constructs the object by calling an appropriate constructor, dependent on the arguments you pass. The second line calls a method on the object.