Qt6 topics merged with General

QAndroidJniObject::callstaticobjectmethod return empty string

  • Hello I have this code:

    QAndroidJniObject string = QAndroidJniObject::callStaticObjectMethod<jstring>("com/app/utils/MyParams", "getEmpty");
    qDebug() << "stringContent:" << string.toString();
    QAndroidJniObject jniParam = QAndroidJniObject::fromString("name" );
     QAndroidJniObject jniParamValue =  QAndroidJniObject::callStaticObjectMethod(
                                "com/app/utils/MyParams" // class name
                                , "getStaticParam" // method name
                                , "Ljava/lang/String;" // signature
                                , jniParam.object<jstring>() );
    qDebug() << "param:" << jniParam.toString();

    on java:

     public static String getStaticParam(String param){
            String realParamName = "Param_ " + param;        
            return realParamName;
    public static String getEmpty(){
        String realPath = "EMPTY";
        return realPath;

    When I call the 'getEmpty' method it works ok, console prints 'stringContent:EMTPY' but when I call the second method it always return an empty string, I don't know why.

    I read that maybe I need to add the return type to the function (QAndroidJniObject::callStaticObjectMethod<jstring>) but doing that gives me an error on QT.

    "no matching function for call to 'callStaticObjectMethod'"

    what Im missing?

Log in to reply