Skip to content

Instantly share code, notes, and snippets.

@ggfan
Created September 23, 2016 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggfan/6ccef9ac609d400e36504134ce0257a7 to your computer and use it in GitHub Desktop.
Save ggfan/6ccef9ac609d400e36504134ce0257a7 to your computer and use it in GitHub Desktop.
#include <android/log.h>
void callingMethod(JNIEnv *env, jobject instance) {
jclass clz = env->FindClass("com/sampleplayer/ar0816/jnitest/MainActivity");
jmethodID fn = env->GetMethodID(clz, "jniCallingmethod", "()V" );
if(!fn ) {
__android_log_print(ANDROID_LOG_ERROR,
"HelloJni",
"Failed to get methodID for jniCallingmethod");
return;
}
// jobject my_instance = env->NewGlobalRef(instance);
// env->CallVoidMethod(my_instance, fn);
// env->DeleteGlobalRef(my_instance);
env->CallVoidMethod(instance, fn);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment