linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] How to call JNI Method in Linphone library


From: Amine Ghabi
Subject: [Linphone-developers] How to call JNI Method in Linphone library
Date: Tue, 30 May 2017 14:55:06 +0200

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  
Amine Ghabi
Ingénieur iOS & Android 
t. 06 03 81 87 91   
a. 242 Rue de Bercy, 75012 Paris
Facebook  Google +  LinkedIn  Amin.ghabi1  Github 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]