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. Android: Camera asking for permissions continuously
Forum Updated to NodeBB v4.3 + New Features

Android: Camera asking for permissions continuously

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 2 Posters 832 Views 1 Watching
  • 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.
  • N Offline
    N Offline
    Nulik
    wrote on last edited by Nulik
    #1

    I have a QML object Camera ,defined like this:

    ```
    Camera
    {
        id: camera
        cameraState: Camera.UnloadedState
        focus {
            focusMode: CameraFocus.FocusContinuous
            focusPointMode: CameraFocus.FocusPointAuto
        }
    }
    
    
    

    When the App starts in Android platform, after QML files are loaded, Qt starts asking permissions for the Camera and the user is continuously prompted by showing a dialog like "Allow App to take pictures and record video?" until he/she is finally forced to say "Yes", but I don't have the camera screen yet being shown to the user, it may even never show if the User won't request it.

    So, how do I tell Qt to do not ask permissions for the camera , until it is really needed?

    My code to start the camera goes like this:

    
        ```
    function init_qr_scaning(p_is_address) {
            camera.cameraState=Camera.ActiveState
            is_address_scanning=p_is_address
            qr_code_avatar.clear()
            camera.start()
        }
    
    raven-worxR 1 Reply Last reply
    0
    • N Nulik

      I have a QML object Camera ,defined like this:

      ```
      Camera
      {
          id: camera
          cameraState: Camera.UnloadedState
          focus {
              focusMode: CameraFocus.FocusContinuous
              focusPointMode: CameraFocus.FocusPointAuto
          }
      }
      
      
      

      When the App starts in Android platform, after QML files are loaded, Qt starts asking permissions for the Camera and the user is continuously prompted by showing a dialog like "Allow App to take pictures and record video?" until he/she is finally forced to say "Yes", but I don't have the camera screen yet being shown to the user, it may even never show if the User won't request it.

      So, how do I tell Qt to do not ask permissions for the camera , until it is really needed?

      My code to start the camera goes like this:

      
          ```
      function init_qr_scaning(p_is_address) {
              camera.cameraState=Camera.ActiveState
              is_address_scanning=p_is_address
              qr_code_avatar.clear()
              camera.start()
          }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Nulik
      only create the camera item when it is needed. (using either a Loader or Component.createObject())

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      N 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @Nulik
        only create the camera item when it is needed. (using either a Loader or Component.createObject())

        N Offline
        N Offline
        Nulik
        wrote on last edited by
        #3

        @raven-worx said in Android: Camera asking for permissions continuously:

        @Nulik
        only create the camera item when it is needed. (using either a Loader or Component.createObject())

        Thanks, but I wanted to avoid it because I will have to re-run all the tests again.

        raven-worxR 1 Reply Last reply
        0
        • N Nulik

          @raven-worx said in Android: Camera asking for permissions continuously:

          @Nulik
          only create the camera item when it is needed. (using either a Loader or Component.createObject())

          Thanks, but I wanted to avoid it because I will have to re-run all the tests again.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Nulik
          so you want to fix a problem without changing something?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          N 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @Nulik
            so you want to fix a problem without changing something?

            N Offline
            N Offline
            Nulik
            wrote on last edited by
            #5

            @raven-worx said in Android: Camera asking for permissions continuously:

            @Nulik
            so you want to fix a problem without changing something?

            No, I want to know why

            cameraState: Camera.UnloadedState
            

            and

            camera.cameraState=Camera.ActiveState
            

            doesn't work as expected

            raven-worxR 1 Reply Last reply
            0
            • N Nulik

              @raven-worx said in Android: Camera asking for permissions continuously:

              @Nulik
              so you want to fix a problem without changing something?

              No, I want to know why

              cameraState: Camera.UnloadedState
              

              and

              camera.cameraState=Camera.ActiveState
              

              doesn't work as expected

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @Nulik said in Android: Camera asking for permissions continuously:

              No, I want to know why ... doesn't work as expected

              because your expectation is wrong ;)
              I guess the code code requests the permission on Android as soon as it is instantiated instead bound to be the cameraState property. Which has system dependent reasons to access the native API i assume.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              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