|
From: | Amine Ghabi |
Subject: | Re: [Linphone-developers] How to call JNI Method in Linphone library |
Date: | Tue, 30 May 2017 15:40:13 +0200 |
Hi,
If you are using linphone library, the following method will return the JNIEnv:
ms_get_jni_env();For it to work properly, the simple way is to add the following in your native code:
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved){ms_set_jvm(ajvm);}Cheers,
Sylvain Berfini Software Engineer @ Belledonne CommunicationsOn 30/05/2017 14:55, Amine Ghabi wrote:
I have implemented a native method that call a java method, here everything is fine but now I need to call this native method in the Linphone C code but I do not know how to do it, here is the example that I did :
JNIEXPORT jstring JNICALL Java_namepackage_getCSR( JNIEnv* env, jobject obj){ jstring jstr = (*env)->NewStringUTF(env, "CSR"); jclass clazz = (*env)->FindClass(env, packageName2); jmethodID generateMthCSR = (*env)->GetMethodID(env, clazz, myMethodName, "(Ljava/lang/String;)Ljava/
lang/String;" ); jobject result = (*env)->CallObjectMethod(env, obj, generateMthCSR, jstr); const char* str = (*env)->GetStringUTFChars(env,( jstring) result, NULL); // should be released printf("%s\n", str); return (*env)->NewStringUTF(env, str); }and now I need to call this native method in the linphone library code so when i try to like this :char *csr = Java_namepackage_getCSR(?, ?); I don't know how to get instance of the JniEnv and the jobject . Thanks for your help
_______________________________________________ Linphone-developers mailing list address@hidden https://lists.nongnu.org/ mailman/listinfo/linphone- developers
_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone- developers
[Prev in Thread] | Current Thread | [Next in Thread] |