jstring -> type name / unexpected expression
-
Hello there,
am trying to call a static Java method which takes a string as argument.
QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object()<jstring>());
I´m getting the error "unexpected type name 'jstring': expected expression" and can´t figure out, if I´m missing to include a library or something else.
Has someone an idea?
-
I think the last line is a little too parentheses-heavy:
QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object<jstring>());
-
@ChrisW67
There is one thing i´m defenetly doing wrong I see now - the 'I' behind the
(Ljava/lang/String;)
is wrong, since I call a void-return method.QJniObject string1 = QJniObject::fromString(song); QJniObject::callStaticMethod<void>( "org/qtproject/example/androidnotifier/MusicPlayer", "play", "(Ljava/lang/String;)I" , string1.object()<jstring>());
May be there is a flaw in the example .
In the c-code part of the following is a comma after the method name "fromNumber"// C++ code QJniObject stringNumber = QJniObject::callStaticObjectMethod("org/qtproject/qt/TestClass", "fromNumber", "(I)Ljava/lang/String;", 10);
while here isn´t a comma after "stringArray"
// C++ code QJniObject string1 = QJniObject::fromString("String1"); QJniObject string2 = QJniObject::fromString("String2"); QJniObject stringArray = QJniObject::callStaticObjectMethod<jstringArray>( "org/qtproject/qt/TestClass", "stringArray" string1.object<jstring>(), string2.object<jstring>());
-
@Flaming-Moe Yes, that is a missing comma in the documentation. Feel free to raise a bug if you cannot find it already reported.
-