C# Call .jar function problem

Could anyone help me how to write a C# listener, I got a java function in Eclipse which is like this:

EgamePay.pay(activity, stringID, new EgamePayListener() {

@Override
public void paySuccess(String alias) {
}
@Override
public void payFailed(String alias, int errorInt) {
}
@Override
public void payCancel(String alias) {
}

});

I export it to .jar file and I try to call it in Unity.
but the problem is I don’t know how to create C# listener

My C# code is something like this: androidJC.Call(“pay”,curActivity, id,egamepayListener);
And I’m sure it working fine, except egamepayListener because i don’t know what should i pass in to there.

You can’t make a Java listener object in C#. However, you can have a regular Java listener call C# methods. The relevant method is com.unity3d.player.UnityPlayer.UnitySendMessage(string unityObjectName, string methodName, string paramToMethod). The class can be found (on my mac) in [UnityInstallDir]/Unity.app/Contents/PlaybackEngines/AndroidPlayer/bin.

For example, you can have a C# game object with the name “EgameListener”, with a method, “void paySuccess(string alias)”. In your Java code, inside paySuccess(String alias), you can write something like “UnityPlayer.UnitySendMessage(“EgameListener”, “paySuccess”, alias)”.

This is documented further here.