I'm trying to call a JNI function from my Java code in an android app, The function is called but the parameters value in the JNI function is not the same as the one passed in the function.
Here are my java declaration and call:
public native void setIA(Integer model);
setIA(1);
And here is my JNI function
extern "C" JNIEXPORT void JNICALL
Java_com_sfy_vitaltechnics_Utils_Parameters_setIA(JNIEnv *env, jobject thiz, jint model) {
LOGD( "This is a number from JNI: %d", model );
}
I get value like -578062932 but it's never the same value.
I tried several cast and type of argument (long, double, float, string and their java equivalent).
And every time it returns a weird value (for string it returns non UTF-8 character).
I think the problem come from my way of declaring the function but I'm not sure
Integer
corresponds to jobject
in C, so you should either alter C function or change java declaration to setIA(int model);
to match existing C function.