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. How to use Camera Lib QML to turn on/off Flash light of Android devices
QtWS25 Last Chance

How to use Camera Lib QML to turn on/off Flash light of Android devices

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 687 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.
  • D Offline
    D Offline
    Drakel
    wrote on 17 Apr 2019, 15:43 last edited by Drakel
    #1

    Hello all, I have a question about how to use Camera Lib Qml, I 've written demo code to turn on/ off flash light of Android device but it hasn't run, I dont know why. My code below :

    Button {
            id: btn
            property bool isClicked: false
            anchors.centerIn: parent
            text: "Click"
    
            onClicked: {
                isClicked = !isClicked
                if (isClicked) {
                    camera.FlashOn
                } else {
                    camera.FlashOff
                }
            }
    }
    
     Camera {
                id: camera
                flash.mode: Camera.FlashTorch
            }
        
    

    I've tried Camera.FlashVideoLight, it run but i can't turn on/off with button onClicked, Can you tell me how to use it ?
    Thank you

    R 1 Reply Last reply 17 Apr 2019, 17:13
    0
    • D Drakel
      17 Apr 2019, 15:43

      Hello all, I have a question about how to use Camera Lib Qml, I 've written demo code to turn on/ off flash light of Android device but it hasn't run, I dont know why. My code below :

      Button {
              id: btn
              property bool isClicked: false
              anchors.centerIn: parent
              text: "Click"
      
              onClicked: {
                  isClicked = !isClicked
                  if (isClicked) {
                      camera.FlashOn
                  } else {
                      camera.FlashOff
                  }
              }
      }
      
       Camera {
                  id: camera
                  flash.mode: Camera.FlashTorch
              }
          
      

      I've tried Camera.FlashVideoLight, it run but i can't turn on/off with button onClicked, Can you tell me how to use it ?
      Thank you

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 17 Apr 2019, 17:13 last edited by
      #2

      @Drakel
      did you specify (Android API <23) in AndroidManifest.xml or request (Android API >= 26) the android.permission.CAMERA permission?

      --- 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
      2
      • D Offline
        D Offline
        Drakel
        wrote on 18 Apr 2019, 14:08 last edited by
        #3

        I used QT version 5.12.2 for windows with JDK 8.0, SDK 26.1.1 and NDK 19.2, it It automatically generates AndroidManifest.xml for me, I see the content of file has <uses-permission android:name="android.permission.CAMERA" /> , I think Qt has added permission. My devices test use android 4.4.2 and 9.0. Can you help to fix that
        Thank you in advance

        R 1 Reply Last reply 18 Apr 2019, 16:40
        0
        • D Drakel
          18 Apr 2019, 14:08

          I used QT version 5.12.2 for windows with JDK 8.0, SDK 26.1.1 and NDK 19.2, it It automatically generates AndroidManifest.xml for me, I see the content of file has <uses-permission android:name="android.permission.CAMERA" /> , I think Qt has added permission. My devices test use android 4.4.2 and 9.0. Can you help to fix that
          Thank you in advance

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 18 Apr 2019, 16:40 last edited by
          #4

          @Drakel
          as i provided the link.
          You need to request the permission at runtime (at least once).

          Also see this, you will see in the Android settings menu if the app has the permission or not.

          --- 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
          2

          2/4

          17 Apr 2019, 17:13

          • Login

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