Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › Using camera on Android

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18509

    Wojciech

    In my v-play environment on a laptop an application takes photos properly. But when I install it on Android camera seems to not be available to a program (it has privilleges to use it). What could be a problem here?

     

     

    #18512

    Alex
    Felgo Team

    Hi,

    can you open the AndroidManifest.xml file in the android-build directory your shadow build directory (you can find this path in the Projects tab in Qt Creator) and check if the correct permission and feature are set?

    <uses-permission android:name="android.permission.CAMERA" />
    
    <uses-feature android:name="android.hardware.camera" android:required="false" />

    If not, you can add them manually in the manifest file in the android directory of your project directory.

    Does this minimal example also not run for you?

    import Felgo 3.0
    import QtQuick 2.9
    
    App {
      id: app
    
      NavigationStack {
    
        Page {
          
          AppButton {
            anchors.centerIn: parent
            text: "Display CameraPicker"
            onClicked: {
              nativeUtils.displayCameraPicker("test")
            }
          }
        }
      }
    }

    Or are you using a different component to access the camera?

    Cheers,
    Alex

    #18514

    Wojciech

    I’m using Camera object in my app, and it is not working, despite I have added what you proposed.

    But your ‘nativeutils’ works – it opens camera. I what way can I get photo image from ‘nativeutils’ ?

    #18517

    Alex
    Felgo Team

    Hi,

    here is another example that shows how to access the image taken with the camera:

    import Felgo 3.0
    import QtQuick 2.9
    
    App {
      id: app
    
      NavigationStack {
    
        Page {
        
          AppImage {
            id: image
            anchors.fill: parent
            // important to automatically rotate the image taken from the camera
            autoTransform: true
            fillMode: Image.PreserveAspectFit
          }
          
          AppButton {
            anchors.centerIn: parent
            text: "Display CameraPicker"
            onClicked: {
              nativeUtils.displayCameraPicker("test")
            }
          }
          
          Connections {
            target: nativeUtils
            onCameraPickerFinished: {
              if(accepted) image.source = path
            }
          }
        }
      }
    }

    The full documentation of the NativeUtils is here: https://felgo.com/doc/nativeutils/

    Cheers,
    Alex

    #18519

    Wojciech

    Thanks, it works perfectly 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.