Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Get data in customActivity from Qt



  • Hi all
    I am new to QtAndroidExtra. I used the example of the QtCreator IDE "CustomActivity" and wanted to know if it is possible to get data in android custom activity from Qt for example
    Qstring myVar = "Hello World" and retrieve it in CustomActivity.java after its start
    String recvVar = myVar
    to use it in a method of the class



  • My question is I want to send data and retrieve it in java. for exeomple

    void ActivityHandler::activityReceiver(int requestCode, int resultCode, const QAndroidJniObject &data)
    {
    if (requestCode == REQUEST_CODE) {
    if (resultCode == RESULT_OK) {

            const QAndroidJniObject key = QAndroidJniObject::fromString("message");
    
            const QAndroidJniObject message = data.callObjectMethod(
                    "getData", "(Ljava/lang/String;)Ljava/lang/String;", key.object());
    
            if (message.isValid())
                emit ActivityHandler::instance()->receiveFromActivityResult(message.toString());
        } else {
            emit ActivityHandler::instance()->receiveFromActivityResult("Rejected!");
        }
    }
    

    }


Log in to reply