Communicate between Java part and C++ part via JNI.

hey guys.
I have ported my ios app to android using android-ndk JNI and C**.
I can successfully communicate from the C** part to the android-ndk Part via JNI - but I don’t know how to send messages the other way- from tha Java part to the C++ part.
Does anybody know how to do this?

Thaks a lot.
Regards.

Wouldn’t be just to call a native method?

Let me explain:

Suppose you want to call a C function char * someFunction(char *p).

1 - You should create a java native method. For instance,

native byte[] myNative(String s);

2 - Then you should create a wapper C function:
JNIEXPORT jbyteArray JNICALL myNative(JNIEnv *, jobject, jstring)

This wrapper C function is the glue that will adapt / convert java parameters with native C because C and Java have different types of variables.

`JNIEXPORT jbyteArray JNICALL myNative(JNIEnv *, jobject, jstring) {
//convert parameters as needed

call someFunction(char *p)

// convert parameters as needed

// return value as appropriated
}
`

3- Call you java function native byte[] myNative(String s)

Hope it helps you.

Regards.


Please,

Site