码迷,mamicode.com
首页 > 其他好文 > 详细

(转)JNI参数传递|Surface

时间:2016-10-14 20:24:00      阅读:335      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!