Qt Android附加调用类
假设我有一个Java类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
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;");