How to use the QT Jni class "QAndroidJniObject" <p>I'm a beginner of "QT for Android" and now I'm using it to develop a communication oftware based on mobile.I hava developed java functions that call android's api as a class in a .java document.In order to Simplify UI development,the UI is based on QT Widget program.Then I use the QT-JNI class "QAndroidJniObject" to call these java functions according to QT5.2 API document.Android resource file is stored in the directory:./android/src/com/comm/sipcall/SipCallSend.java.Since the less information in this regard,I developed the java and c++ program according to API document.But I encountered the following problems, and also hope to get answers: 1) The QT program is based on QT Widget.The java program needs to get the current application object Context in order to initialize java object.The c++ code I developed as following:</p> <pre><code>//c++: QPlatformNativeInterface *interface = QApplication::platformNativeInterface(); jobject activity = (jobject)interface-&gt;nativeResourceForIntegration("QtActivity"); QAndroidJniObject* at = new QAndroidJniObject(activity); QAndroidJniObject appctx = at-&gt;callObjectMethod("getApplicationContext","()Landroid/content/Context;"); //.pro： QT += core gui gui-private </code></pre> <p>Is this right?</p> <p>2) The java class contains a constructor function and three public functions:</p> <pre><code>java: package com.comm.sipcall; improt XXXX .... .... public class SipCallSend extends Activity { private Context context; // 接收QT的context public String sipToAddress = ""; public String sipDomain = ""; public String user_name = ""; public String pass_word = ""; public SipCallSend(){ Log.i("ddd","init"); sipToAddress = ""; sipDomain = ""; user_name = ""; pass_word = ""; } public void SetContext(Context cnt) { this.context = cnt; //Log.i("ccc",user_name); } public int Login(String domain,String username,String password){ .... sipDomain = domain; user_name = username; pass_word = password; ... return 0; } public int Call(String addrNum) { ... return 0; } } C++： QPlatformNativeInterface *interface = QApplication::platformNativeInterface(); jobject activity = (jobject)interface-&gt;nativeResourceForIntegration("QtActivity"); QAndroidJniObject* at = new QAndroidJniObject(activity); QAndroidJniObject appctx = at-&gt;callObjectMethod("getApplicationContext","()Landroid/content/Context;"); QAndroidJniObject* m_sipcall = new QAndroidJniObject("com/comm/sipcall/SipCallSend"); if (!m_sipcall-&gt;isValid()) return; m_sipcall-&gt;callMethod&lt;void&gt;("SetContext","(Landroid/content/Context;)V", appctx.object&lt;jobject&gt;()); QAndroidJniObject domain = QAndroidJniObject::fromString("10.3.56.54"); QAndroidJniObject username = QAndroidJniObject::fromString("1006"); QAndroidJniObject password = QAndroidJniObject::fromString("1234"); jint res = m_sipcall-&gt;callMethod&lt;jint&gt;("Login","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", domain.object&lt;jstring&gt;(), username.object&lt;jstring&gt;(),password.object&lt;jstring&gt;()); if (res!=0) return; QAndroidJniObject addrNum = QAndroidJniObject::fromString("1018"); res = m_sipcall-&gt;callMethod&lt;jint&gt;("Call","(Ljava/lang/String;)I",addrNum.object&lt;jstring&gt;()); </code></pre> <p>The "new QAndroidJniObject" returns non-empty,but the the following functions connot execute,why?</p> <p>3) I have tried to make the Context from c++ as a parameter of constructor function,but I found the code not running,why?</p> <pre><code>java: public SipCallSend(Context cnt){ this.context = cnt; } C++: QAndroidJniObject m_sipcall("com/comm/sipcall/SipCallSend","(Landroid/content/Context;)V",appctx.object&lt;jobject&gt;()); </code></pre> <p>4) According to QT5.2 API document,QAndroidJniObject provides a method named "callObjectMethod":</p> <pre><code>QAndroidJniObject myJavaString; ==&gt; "Hello, Java" QAndroidJniObject mySubstring = myJavaString.callObjectMethod("substring", "(II)Ljava/lang/String;" 7, 10); </code></pre> <p>But when I use it as following, the IDE prompts me the parameter are incorrect,why?</p> <pre><code>jint res = m_sipcall-&gt;callMethod&lt;jint&gt;("Login","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", domain.object&lt;jstring&gt;(), username.object&lt;jstring&gt;(),password.object&lt;jstring&gt;()); </code></pre> <p>Thanks...</p>