I want to use JNI (Java Native Interface) to call a specific java setter method, passing a short[] buffer into it as a parameter.
Java method implimentation looks as follows:
public void setPcmLeft(short[] data) { pcm_l = data; }
From inside my C function how can I call this method using JNI.
My code currently looks like this:
void Java_com_companyName_lame_LameActivity_lameDecode(JNIEnv *env, jobject jobj)
{
jclass class = (*env)->GetObjectClass(env, jobj);
if (class != NULL) {
jmethodID setLeftDatatID = (*env)->GetMethodID(env, class, "<setPcmLeft>", "void(V)");
if (setLeftDatatID == NULL) {
LOGD("(Lame) No method setLeftData");
}
}
}
When I run this, the setLeftDataID
is allays NULL
.
Note that the jobj
parameter is my object being passed in that contains the setPcmLeft
implementation.