How to call camera and file selector with qml webview on android ?
Solved
Mobile and Embedded
-
wrote on 24 Feb 2025, 12:45 last edited by
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? -
-
wrote on 26 Feb 2025, 06:06 last edited by
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/2