調用靜態方法java
jmethodID cb = env->GetStaticMethodID(thiz, "createBitmap", "(II)Landroid/graphics/Bitmap;"); jobject bitmap = env->CallStaticObjectMethod(thiz, cb, metaInfo.dataW, metaInfo.dataH);
給變量賦值android
jclass snapInfoClass = env->FindClass("com/example/jni/SnapInfo"); jmethodID constructor = env->GetMethodID(snapInfoClass, "<init>", "()V"); jobject jSnapInfo = env->NewObject(snapInfoClass, constructor); jfieldID jexpTimeId = env->GetFieldID(snapInfoClass, "expTime", "[I"); jintArray jexpTime = env->NewIntArray(snapInfo.realNum); jint* expTime = env->GetIntArrayElements(jexpTime, NULL); //向expTime賦值 env->ReleaseIntArrayElements(jexpTime, expTime, JNI_OK); env->SetObjectField(jSnapInfo, jexpTimeId, jexpTime);
package com.example.jni; public class SnapInfo { public int[] expTime; public float[] expGain; public int[] expNum; public int realNum; public int costTime; }