(转)JNI参数传递|Surface
Posted wainiwann
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(转)JNI参数传递|Surface相关的知识,希望对你有一定的参考价值。
http://blog.csdn.net/stefzeus/article/details/6622011
char* Get_Surface(JNIEnv *env, jclass cls, jobject param, int sdk_version) { // Java层 jfieldID surface = env->GetFieldID(cls, "mSurface", "Landroid/view/Surface;"); jobject surface_cls = env->GetObjectField(param, surface); // Native层 jclass surface_class = env->FindClass("android/view/Surface"); jfieldID surface_native = env->GetFieldID(surface_class, "mSurface", "I"); //"I"指整型 // the JNI also supports other functions such as GetIntField and SetFloatField for accessing instance fields of primitive types. return (char*)(Surface*)env->GetIntField(surface_cls, surface_native); } 理解GetIntField (char*)(Surface*)env->GetIntField(surface_cls, surface_native); Once you have obtained the field ID, you can pass the object reference and the field ID to the appropriate instance field access function: jstr = (*env)->GetObjectField(env, obj, fid);
以上是关于(转)JNI参数传递|Surface的主要内容,如果未能解决你的问题,请参考以下文章
从本机 c 代码 (JNI) 为 Java 中的回调函数传递多个参数
[转]JNI:使用RegisterNatives方法传递和使用Java自定义类