Solved Android: Camera asking for permissions continuously
-
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() }
-
@Nulik
only create the camera item when it is needed. (using either a Loader or Component.createObject()) -
@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.
-
@Nulik
so you want to fix a problem without changing something? -
@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
-
@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.