首页 > 其他 > 详细

(转)JNI参数传递|Surface

时间:2016-10-14 20:22:13      阅读:279      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/wainiwann/p/5961825.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!