I am testing some features with Android, JNI and NDK.
I have the following JAVA class:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class JNITest extends Activity {
private int contador;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
contador = 0;
TextView label = (TextView)findViewById(R.id.Text);
label.setText(Integer.toString(contador));
}
public void addClick(View addButton) {
nativeAdd(1);
TextView label = (TextView)findViewById(R.id.Text);
label.setText(Integer.toString(contador));
}
private static native void nativeAdd(int value);
static {
System.loadLibrary("JNITest01");
}
}
I used javah -jnito create the header file:
#include <jni.h>
#ifndef _JNITestNative
#define _JNITestNative
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_com_xxxxx_tests_JNITest_nativeAdd
(JNIEnv *, jclass, jint);
#ifdef __cplusplus
}
#endif
#endif
As you can see, the second parameter is jclass .
I am wondering how can I change jclass for the jobject parameter .
I need a jobject parameter to get the value from the field of the class that calls this native function.
How to change the signature of a method? or how can I get the job from the jclass parameter?
Thank.
source
share