So I've worked with the ndk/c/c++ a little bit, and I know about the jbooleanArray var type, but my question is how would I go about creating a 2d boolean array and returning it to the Java to be used? Here's an example:
#include "retrieveboolarray.h"
#define LOG_TAG "!"
//macros to call the Log functions to allow for debugging. the tag is declared on the line above
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
JNIEXPORT jint JNICALL Java_com_example_ndktesting_generateBoolArrays_retrieveBoolArray(
JNIEnv * env, jobject obj, jint refNum) {
//refNum will eventually be used to access certain arrays
return refNum;
}
so right now it's returning an integer, how would I generate a 2d bool array and return it to the Java?
update: here is some code I've tried previously, still with no luck unfortunately
JNIEXPORT jobjectArray JNICALL Java_com_example_ndktesting_generateBoolArrays_retrieveBoolArray(
JNIEnv * env, jobject obj, jint refNum) {
jboolean flag = JNI_TRUE;
jclass stringClass = (*env)->FindClass(env, "java/lang/Boolean");
jobjectArray row;
jobjectArray rows;
jboolean hello = 1;
int MAXRESPONSE = 5;
int MAXTEST = 5;
jsize i, j;
for (i = 0; i < 5; i++) {
row = (*env)->NewObjectArray(env, MAXRESPONSE, stringClass, 0);
for (j = 0; j < 3; j++) {
(*env)->SetObjectArrayElement(env, row, j, hello);
}
if (flag == JNI_TRUE) {
flag = JNI_FALSE;
rows = (*env)->NewObjectArray(env, MAXTEST,
(*env)->GetObjectClass(env, row), 0);
}
(*env)->SetObjectArrayElement(env, rows, i, row);
}
return rows;
}
hopefully someone has an idea on how to fix this so I can make/return a bool array.