Important: Please read the Qt Code of Conduct -

Repeated Camera Permission requests at App installation (around 10time by using qt camera example)

  • Here using QT example: declarative-camera.
    Qt 5.11.1
    Tablet: SDK24, Android 7.

    Here do not consider run-time permission (this part, works very well).

    I am developing a app and will use camera to capture some images, and meet a camera permission question. Here use QT camera example for demo this question:

    After Created Templates in Build Settings (Minium API 21, Target SDK API26, and add a application icon, Add android.permission.CAMERA), When install declarative-camera,
    will popup permission request dialog, if click "Deny", will popup again with "Don't ask again", if click Deny (and not select Don't ask again), will popup dialog again and again (here 10 times).
    If click "Deny":


    Q0. Why SO MANY permission request dialog if user click deny?
    And SDK is 24, should be runtime request permissions instead of request at installation, any reason?
    Even click "Deny" for all popup dialog, still could start app, looks this is not android installation permission, right? (because if it is android installation permissions, if click deny, should not start APP.)

    Q1. how to disappear these permission requests?
    Q2. whether could set default value is "Don't ask again", so when a user click "Deny", will not popup these requests. And will only ask permission request at runtime.

    Q3: the same app build on IOS, popup permission request, if click "Don't Allow", will not popup permission requests (this behaviour is perfect). But for IOS, when runtime use this camera (did not sign camera permission at installation stage), QtMultimedia.availableCameras.length return 2. (for android, here return 0 if has no permission). IOS show camera in black and camera could not use (here QtMultimedia.availableCameras.length is used to decide whether to start camera or not, but for IOS, it looks this method does not work), I am still working on this, please share your suggestions. how to request permission during run-time for IOS and detect no permission granted (like this case, QtMultimedia.availableCameras.length return 2, but has no permission). Many thanks.
    More hints about IOS: not matter sign camera permission at installation stage, these has the same values (QtMultimedia.availableCameras.length:2, camera.cameraStatus: 8, camera.availability:0, camera.cameraState:2). How to get camera permission status at runtime in IOS?

    For Q2, I am trying to add function in main.cpp (this example is qmycamera.cpp), and want to popup a request first, if user deny, will parse this"Deny" to some Android lib to set "Don't ask again" as a default. So will not repeated popup request. But even get the Denied, what is next step or other methods to solve repeated request??

    for(const QString &permission : permissions){
        int androidSDKVersion = QtAndroid::androidSdkVersion(); // SDK decide checkpermission
        auto result = QtAndroid::checkPermission(permission);
        if(result == QtAndroid::PermissionResult::Denied){
            auto resultHash = QtAndroid::requestPermissionsSync(QStringList({permission}));
            if(resultHash[permission] == QtAndroid::PermissionResult::Denied){
                if(permission == "android.permission.CAMERA"){
                  // ?? how to parse this Denied result to qandroindfunction, and set shouldShowREquestPermissionRationale, return false, which means user denied and select "Don't ask again"
                    bool showRationale = QtAndroid::shouldShowRequestPermissionRationale(permission);
                //return 0; //just directly quit app.


    Thanks for comments and suggestions.

Log in to reply