I have to call a Java method from JNI. This Java method returns int array (int[] simpleMethod()). How to call this from JNI to get the array as a return value? I know how to do this when method returns void/String/int/etc but couldn't find anything with arrays. I have some ideas how to work around this but maybe there is simple answer.
Use CallObjectMethod
. For example:
jmethodID myMethod = (*env)->GetMethodID(myClass, "myMethod", "()[I");
jintArray retval = (jintArray) (*env)->CallObjectMethod(myObject, myMethod);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With