Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt Android附加调用类_Android_Qt_Java Native Interface_Qtandroidextras - Fatal编程技术网

Qt Android附加调用类

Qt Android附加调用类,android,qt,java-native-interface,qtandroidextras,Android,Qt,Java Native Interface,Qtandroidextras,假设我有一个Java类 public static String helloWorld() { return "hello world!"; } 在Qt中,我如何获得这个函数返回的内容?通知示例包括以下内容: QAndroidJniObject javaNotification = QAndroidJniObject::fromString(m_notification); QAndroidJniObject::callStaticMethod<void>("org/qtp

假设我有一个Java类

public static String helloWorld() {
    return "hello world!";
}
在Qt中,我如何获得这个函数返回的内容?通知示例包括以下内容:

QAndroidJniObject javaNotification = QAndroidJniObject::fromString(m_notification);
QAndroidJniObject::callStaticMethod<void>("org/qtproject/example/notification/NotificationClient",
                                   "notify",
                                   "(Ljava/lang/String;)V",
                                   javaNotification.object<jstring>());
QAndroidJniObject javaNotification=QAndroidJniObject::fromString(m_通知);
QAndroidJniObject::callStaticMethod(“org/qtproject/example/notification/NotificationClient”,
“通知”,
“(Ljava/lang/String;)V”,
javaNotification.object());
方法描述符应该是
()Ljava/lang/String
callStaticMethod
之后的V形符号中应该是什么

编辑。修好了,我不知道怎么修。我没有雪佛龙,描述是正确的

QAndroidJniObject string = QAndroidJniObject::callStaticObjectMethod<jstring>("com/your/project/YourClass", "helloWorld");
对于普通签名,即不带参数并返回已知jni类型之一的签名,您可以通过提供模板类型来编写简短版本

QAndroidJniObject string = QAndroidJniObject::callStaticObjectMethod("com/your/project/YourClass", "helloWorld", "()Ljava/lang/String;");