C Function which I want to convert below how I declare and call callback.
typedef void (*GenmsgCallback_t)(char *genmsgResponse, size_t genmsgResponseLen);
void genmsg_cb(char *rcvData, size_t rcvDataLen) {
for (int i = 0; i < rcvDataLen; i++) {
printf("%c", rcvData[i]);
}
printf("\n");
}
How I call the callback with the main
function
retVal = init_genmsg_module(genmsg_cb, RootConfigFilePath_Gen_Msg);
//Declaration for main function goes like this
int init_genmsg_module(GenmsgCallback_t fnptrGenmsgCb, const char *rootCfgFilePath);
I want to change the C function to JAVA code over ndk. I have done one caller fucntion like this which internally call the C function it self but the cb I am not able to create via JAVA so I can call the main
function.
JNI code goes like this:
JNIEXPORT jint JNICALL Java_com_example_genralmsg_1module_caller_1genmsg_initgenmsg(JNIEnv *env, jclass caller_genmsg,jstring rootFilePath){
const char *filepath = (*env)->GetStringUTFChars(env, rootFilePath, 0);
return init_genmsg_module(genmsg_cb,filepath);
}