I have writing Aar library file, this needs to be linked with the Android APP which has Asynchronous calls to this library using JNI Call. These JNI Calls needs to be invoke the corresponding Functions on the Class file.
Android Asynchronous calls -> c++ JNI -> library(aar)
Here aar file has JNI Reception and calls to the Android Class file. From JNI we need to pass the context to the Android Class file.
Control is coming to the JNIClass_Initialize() where the context and jenv_obj being passed.
From Here not able to find class, as this Class was not initiated.
How to initiate the Class file from JNI Interface.
The following is the code:
Getting
int JNIClass_Initialize(
void *context
, void *jenv_obj
) {
//Not able to initiate or invoke Class functions.
jclass cls = (jniEnvVal.env)->FindClass("ae/info/TestReader");
//Here it is crashing - As not getting the class
jmethodID initFun1= (jniEnvVal.env)->GetStaticMethodID(cls, "Init_func", "(Landroid/content/Context;)I");
jint retVal = (jniEnvVal.env)->CallStaticIntMethod(cls, initFun1= ,context);
}
public class TestReader{
Init_func(Context cnt) {
//Process it
}
}
Thanks for any Help.