I need to call various Java functions while in native C++ to do some stuff (loading gfx, etc...) and would like to know how. Does anyone of you know some samples or have a few helpful code snippets ?
Asked
Active
Viewed 2,212 times
1
-
1Try to use search: [http://stackoverflow.com/questions/5198105/calling-a-java-method-from-c-in-android][1] [1]: http://stackoverflow.com/questions/5198105/calling-a-java-method-from-c-in-android – Yury Dec 22 '11 at 22:33
-
I used the search but must have missed that. Anyway, that was exactly what I was looking for and it works, thanks ! – HardCoder Dec 23 '11 at 07:39
1 Answers
2
To call Java functions from NDK you have to use JNI.
A useful and simple example is provided at the following link:
But I suggest that you should:
- Not create a new Java Virtual Machine as in the above example. Instead you should use the JavaVM* and JNIEnv* that you get when you call the NDK functions.
- Be careful for memory leaks when you use NDK.

npal
- 529
- 4
- 11