Sample Syntax Declaration for NDK


Getting Static String from JNI
              env->NewStringUTF("I am back with string!");

Access Fields Declared in java class (public float[] VertexCoords;)

1. jclass cls = env->GetObjectClass(obj); //obj is the object of java class
2. jfieldID fieldId = env->GetFieldID(cls, "VertexCoords", "[F");
                     // VertexCoords is the name of variable defined in java
                    // [F defines the type of variable it is array float
3. jobject objArray = env->GetObjectField (obj, fieldId);
                 // Take the field in jobject.
4. jfloatArray* fArray = reinterpret_cast<jfloatArray*>(&objArray);
               // Cast it to jfloatArray
5. jsize len = env->GetArrayLength(*fArray);
             //get the length of float array
6. float* data = env->GetFloatArrayElements(*fArray, 0);
            //get all data
after getting data perform the task according to your requirements

7. env->ReleaseFloatArrayElements(*fArray, data, 0);
          //Dont forget to release the pointer array

   

Access Methods Declared in java class (public int getFacetCount(){})

     jclass cls = env->GetObjectClass(obj);
    jmethodID methodId = env->GetMethodID(cls, "getFacetCount", "()I");
    int result = env->CallIntMethod(obj, methodId);

Comments

  1. Playtech adds virtual reality casino slots to Google Play
    The 평택 출장안마 content 평택 출장마사지 provider has announced its latest virtual reality slot machines, 세종특별자치 출장마사지 featuring Big Santa, The Lion King, Go 서산 출장샵 Fish, 경주 출장안마 Go Fish and a

    ReplyDelete

Post a Comment

Popular posts from this blog

Bluetooth Data Transfer Example

How to Create & Extract tar.gz and tar.bz2 Files in Linux