I know we can use JNI to interact java and c++, but during my project, I want to complete the network in the java code, after that I want to leave the java code, and evoke the callback function in Cocos code.
Asked
Active
Viewed 42 times
1 Answers
0
make a callback in Java; in that java_callback() invoke a JNI function; in the JNI function, invoke a cocos_callback(); and there you have it ;)

Shark
- 6,513
- 3
- 28
- 50
-
thank you for your answer! However, I cannot follow your step, because we need invoke `System.loadLibrary(dynamic link library)` in the java code before we invoke a JNI function, could you please show me a demo code? – glensun Jan 26 '16 at 03:11
-
It's not so easy showing demo code of C/Java code. Look at these two topics: http://stackoverflow.com/questions/12214707/properly-returning-a-hardcoded-byte-from-jni-to-java http://stackoverflow.com/questions/8532642/c-to-java-calls-pass-but-jvm-crashes-in-a-weird-unexplained-way – Shark Jan 26 '16 at 09:34
-
1Thanks! :) I have already solved this problem by invoke `System.loadingLibrary(cocos2dcpp)`in the java code. Thank you very much. :) – glensun Jan 27 '16 at 05:21