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

Restart application and connect to already running Android service



  • Hi,

    I have 2 questions regarding Android service. I created one for my application using this guide. It works fine so fast. But after (I do believe) upgrade to Qt 5.11, I get a Semantic Issue warning on this command:

    QAndroidJniObject::callStaticMethod<void>("com/kdab/training/MyService",
                                                  "startMyService",
                                                  "(Landroid/content/Context;)V",
                                                  QtAndroid::androidActivity().object());
    

    After starting the service I use RemoteObjects to connect the service and my application. The code to do it looks like this:

    repNode = new QRemoteObjectNode(this);
    repNode->connectToNode(QUrl(QStringLiteral("local:replica")));
    service = repNode->acquire<MyServiceReplica>();
    bool res = service->waitForSource();
    if (res) {
       service->registerRecievers();
    }
    

    It works fine if the service is not running. But what should I do if the service is already running, my application closes and then I start it again? I don't want to restart the service but only connect it with my application.


Log in to reply