Issue with requesting permissions on Android
Unsolved
Mobile and Embedded
-
I use QtAndroidPrivate namespace to check and request different permissions in runtime. Function to check whether permission is already granted and request it if necessary looks like this
bool checkAndAcquirePermissions( const QString &permissionString ) { auto r = QtAndroidPrivate::checkPermission( permissionString ).result(); if ( r == QtAndroidPrivate::Denied ) { r = QtAndroidPrivate::requestPermission( permissionString ).result(); if ( r == QtAndroidPrivate::Denied ) { return false; } } return true; }
When app tries to check permission with
checkPermission()
call I see a dialog asking for a permission. If I grant permission at this point, everything is fine. However if permission is not given then app freezes at therequestPermission()
call and eventually crashes. Am I doing something wrong?Tested on two devices (Andoid 7 and 10), Qt 6.4.1
-
This is your job to handle it. If permission is not granted, you stop your app or pop up a dialog to tell the user that the app can not continue.
1/2