## 反射的复习 ##
//1.装载字节码
Class> clazz = Demo.class.getClassLoader().loadClass("Dialog");
//2.查找方法
Method method = clazz.getDeclaredMethod("showDialog", String.class);
//3.调用方法
method.invoke(clazz.newInstance(), "利用反射调用Dialog中的showDialog方法");
## C调用java中方法的步骤 ##
//1.find class
//jclass (*FindClass)(JNIEnv*, const char*);
jclass clazz = (*env)->FindClass(env,"com/itheima/alipay01/MainActivity");
//2.get method id
//jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*);
jmethodID methodid = (*env)->GetMethodID(env, clazz, "showDialog", "(Ljava/lang/String;)V");
//3.call void methoid
//void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...);
(*env)->CallVoidMethod(env, obj, methodid, "yong hu mi ma");
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4222/viewspace-2814790/ ,如需转载,请注明出处,否则将追究法律责任。