I'm trying to add in-app billing in my cocos2dx-android project. I am able to give a call to java function from c++ class via jni.
This is the way i give a call to my java function via jni.
JniMethodInfo t;
JniHelper::getStaticMethodInfo(t
, "com/test/project/Project"
, "BuyProduct"
, "(Ljava/lang/String;)V");
char buffer[20];
sprintf(buffer,"product1");
jstring StringArg1 = t.env->NewStringUTF(buffer);
t.env->CallStaticVoidMethod(t.classID, t.methodID, StringArg1);
The in-app billing is working fine, but now i have to give a call back to my c++ class to inform if the product purchase was successful or not.
I could return the result from the called method only by mentioning the specified return type, but the in-app process being a asynchronous process-goes through a lot of method calls, and my control is not returned back to the same method. So returning a value would not work.
So is there any other way of passing a value(in my case the result of in-app purchase) to my c++ class from java function???