android jni 调用static native void method

java:

class A{

public static void getJNI()
{
 nativeGetJNI();
}

private static native void nativeGetJni();
}

c++

.....

static void cn_com_native_getJNI(JNIEnv *, jobject)

.....
}

....
 static JNINativeMethod  jniMethods[]={

{"nativeGetJni","()V",(void*)cn_com_native_getJNI},
}

......

 注意  cn_com_native_getJNI 函数需要static 修饰

当然需要再onload.cpp 里注册,因为这个忘写了,搞了好久

猜你喜欢

转载自huaonline.iteye.com/blog/1745448