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 call camera and file selector with qml webview on android ?
Forum Update on Monday, May 27th 2025

How to call camera and file selector with qml webview on android ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 134 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.
  • L Offline
    L Offline
    LZHD
    wrote on last edited by
    #1

    I have written permissions in AndroidManifest.xml.

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

    request in qml

    WebView{
     
            settings.allowFileAccess: true
            settings.javaScriptEnabled: true
            settings.localContentCanAccessFileUrls: true
            settings.localStorageEnabled: true
    }
    CameraPermission {
            id:cameraPermission
    
        }
     Component.onCompleted: cameraPermission.request()
    

    The same website in the browser can call the camera and file selector, but it doesn't work in the webview. I also tried to open Filedialog(QtQuick.Dialogs) directly, and it can work.
    Is there a way to solve it?

    1 Reply Last reply
    0
    • L LZHD has marked this topic as solved on
    • L Offline
      L Offline
      LZHD
      wrote on last edited by
      #2

      It requires rewriting WebChromeClient in Java or Kotlin, but there is no way to set it for QML webview. It seems that you can only use JNI to start the Android activity as the webview view.

      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