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 arguement(long, double, float, string and thir java equivalent). and everytime it give me weird value(for string it give me non UTF-8 character) I think the problem come from my way of declaring the function but I'm not sure
CodePudding user response:
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.