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

Cannot grant permission for "android.permission.ACCESS_WIFI_STATE"



  • I've tried using QtAndroid::requestPermissionsSync(QStringList({"android.permission.ACCESS_WIFI_STATE"})) before any JNI calls and also including the permission in my AndroidManifest.xml file, but without success; Art reports that my app still doesn't have permission. What can I do to ensure that my App does have that permission?



  • It turns out that I had failed to copy my modified AndroidManifest.xml file, as qmake had copied the default manifest without the required permission tag. Make sure that you have included an assignment to ANDROID_PACKAGE_SOURCE_DIR under the android block in your qmake project file:

    android {
      QT += androidextras
      ANDROID_PACKAGE_SOURCE_DIR = \
        $$PWD/android
    }
    

    I couldn't request the permission with QtAndroid::requestPermissionsSync because the underlying Android API method only works for dangerous permissions: android.permission.ACCESS_WIFI_STATE is classed as a normal permission.


Log in to reply