Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ndk; How to create a 2d boolean array in c/c++ and return it to the Java?
    primarykey
    data
    text
    <p>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:</p> <pre><code>#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; } </code></pre> <p>so right now it's returning an integer, how would I generate a 2d bool array and return it to the Java?</p> <p>update: here is some code I've tried previously, still with no luck unfortunately</p> <pre><code>JNIEXPORT jobjectArray JNICALL Java_com_example_ndktesting_generateBoolArrays_retrieveBoolArray( JNIEnv * env, jobject obj, jint refNum) { jboolean flag = JNI_TRUE; jclass stringClass = (*env)-&gt;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 &lt; 5; i++) { row = (*env)-&gt;NewObjectArray(env, MAXRESPONSE, stringClass, 0); for (j = 0; j &lt; 3; j++) { (*env)-&gt;SetObjectArrayElement(env, row, j, hello); } if (flag == JNI_TRUE) { flag = JNI_FALSE; rows = (*env)-&gt;NewObjectArray(env, MAXTEST, (*env)-&gt;GetObjectClass(env, row), 0); } (*env)-&gt;SetObjectArrayElement(env, rows, i, row); } return rows; } </code></pre> <p>hopefully someone has an idea on how to fix this so I can make/return a bool array.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload