GetObjectArrayElement
jobject GetObjectArrayElement(JNIEnv *env,
jobjectArray array, jsize index);
Returns an element of an
Object
array.LINKAGE:
Index 173 in the JNIEnv interface function table.PARAMETERS of GetObjectArrayElement
env
: the JNI interface pointer.array
: a Java array.index
: array index.RETURNS of GetObjectArrayElement
Returns a Java object.
THROWS:
ArrayIndexOutOfBoundsException
: if index
does not specify a valid index in the array.
Example of GetObjectArrayElement
void MyJNIFunction(JNIEnv *env, jobject object, jobjectarray stringArray) {
int stringCount = GetArrayLength(env, stringArray);
for (int i=0; i<stringCount; i++) {
jstring string = (jstring) GetObjectArrayElement(env, stringArray, i);
const char *rawString = GetStringUTFChars(env, string, 0);
// Don't forget to call `ReleaseStringUTFChars` when you're done.
}
}