Howard Lang
Howard Lang

Reputation: 31

On Android, can Java call JNI and then the JNI calls back into Java?

I am just learning android and JNI. Within Java, from a button click a JNI is being called. Within the called JNI I call back into Java. Leaving out the error processing and trying to call a static void method with no parms:

void Java_com_example_ndk2_AndroidNDK1SampleActivity_callme(JNIEnv * env, jobject this, int i)
{
   jclass handlerClass = (*env)->FindClass(env, "com/example/ndk2/AndroidNDK1SampleActivity");
   jmethodID mid = (*env)->GetStaticMethodID(env, handlerClass, "JavaCallback","()V");
   (*env)->CallStaticVoidMethod(env, mid, NULL);
}

The FindClass and GetStaticMethodID are NOT returning errors. On the call back to Java, Logcat is indicating from dalvikvm: Invalid indirect reference 0xxxx in decodeIndirectRef. Any suggestions would be welcome.

Upvotes: 3

Views: 183

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20812

Remove the parameter (NULL) you are passing when invoking a method that takes none ("()V").

Upvotes: 3

Related Questions