Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt + Android and WiFi

Qt + Android and WiFi

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
10 Posts 2 Posters 6.2k Views
  • 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.
  • QojoteQ Offline
    QojoteQ Offline
    Qojote
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • QojoteQ Offline
        QojoteQ Offline
        Qojote
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          1
          • QojoteQ Offline
            QojoteQ Offline
            Qojote
            wrote on last edited by
            #5

            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
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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
              0
              • QojoteQ Offline
                QojoteQ Offline
                Qojote
                wrote on last edited by
                #7

                Yes, i did.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by SGaist
                  #8

                  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
                  0
                  • QojoteQ Offline
                    QojoteQ Offline
                    Qojote
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      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
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved