Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a jobject array ? (Jni)

In fact, I call a c++ function :

JNIEXPORT void JNICALL Java_test_main_JniFunctions_testObject (JNIEnv *env, jobject obj, jobjectArray objArray){....}

And what I'd like to do, is get back the original object's values. Considering the java code declaration for this object :

jniFct.testObject(new Object[][]
        {   
            {"testTable"},
            {0, 0.0, "aaa"},
            {1, 1.1, "bbb"},
            {2, 2.2, "ccc"}
        });

In exemple, get the value from the third row in the second column.

Anybody's got an idea on how to do it ??

like image 653
Jsncrdnl Avatar asked Nov 10 '11 13:11

Jsncrdnl


1 Answers

jobject row = env->GetObjectArrayElement(objArray, 2);
jobject value = env->GetObjectArrayElement((jobjectArray)row, 1);
const char* cvalue = env->GetStringUTFChars((jstring)value, 0);
like image 105
weekens Avatar answered Oct 05 '22 02:10

weekens