jstring stringFromJNI(JNIEnv* env,jobject thiz){
return env->NewStringUTF("123465");
}
static JNINativeMethod gMethods[]={
{"stringFromJNI","()Ljava/lang/String;",(void*)stringFromJNI}
};
static int registerNativeMethods(JNIEnv* env, const char* className,JNINativeMethod* gMethods,int numMethods){
jclass clazz;
clazz=env->FindClass(className);
if(clazz==NULL){
return JNI_FALSE;
}
if(env->RegisterNatives(clazz,gMethods,numMethods)<0){
return JNI_FALSE;
}
return JNI_TRUE;
}
static int registerNatives(JNIEnv* env){
const char* kClassName="com/example/jnionload/MainActivity";
return registerNativeMethods(env, kClassName, gMethods, sizeof(gMethods)/ sizeof(JNINativeMethod));
}
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm,void* reserved){
JNIEnv* env=NULL;
jint result=-1;
if((vm->GetEnv((void **) &env, JNI_VERSION_1_6))!=JNI_OK){
return -1;
}
assert(env!=NULL);
if(!registerNatives(env)){
return -1;
}
return JNI_VERSION_1_6;
}