Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Qt + Android and WiFi

    Mobile and Embedded
    2
    10
    5463
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Qojote
      Qojote last edited by

      Hello,

      I am writing an app for an android device and i am wondering if it is possible to enable and disable the Wifi within my app?

      Best regards

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        I haven't tested that with Android but the Bearer Manager might be what your are looking for.

        Hope it helps

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • Qojote
          Qojote last edited by

          Hi,

          Yes, i read the article. When i run

          QNetworkConfigurationManager manager;
          const bool canStartIAP = (manager.capabilities()
                                        & QNetworkConfigurationManager::CanStartAndStopInterfaces);
          

          canStartIAP is false. My app has all permissions to edit the wifi state.
          Furthermore, wheni try the following code:

           QNetworkConfigurationManager ncm;
           QList<QNetworkConfiguration> nc = ncm.allConfigurations();
          
          foreach( QNetworkConfiguration item, nc )
          {
             if (item.bearerType() == QNetworkConfiguration::BearerWLAN)
            {
               qDebug() << "Wifi" << item.name();
               qDebug() << "state" << item.state();
            }
          }
          

          then i see that my app knows that there exist a mobile and wifi network but the state is alway 0x2.
          I am also able to use androidextras to run java code and use the wifimanager to switch on wifi (which works), but it would be nicer to use Qt-Code only...

          Best regards

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            From a quick look at the code, it seams that changing the connection state is currently not supported so you are on the correct track using the QtAndroidExtras module

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • Qojote
              Qojote last edited by

              Thanks for your advice.
              I've got one more question:

              On my Android device the QNetworkConfigurationManager only lists "Mobile" and "Wifi" but not the names of the available WLANs. Does this have to be done externally as well?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Did you call QNetworkConfigurationManager::updateConfigurations ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • Qojote
                  Qojote last edited by

                  Yes, i did.

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by SGaist

                    Which version of Android ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 0
                    • Qojote
                      Qojote last edited by

                      My device runs android 5.1.1 and i am using Qt 5.5.1.

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        Since Qt 5.6.0 is out, can you check again with it ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post