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. Issue with requesting permissions on Android
QtWS25 Last Chance

Issue with requesting permissions on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
androidpermissionsqt6.4.1
2 Posts 2 Posters 462 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.
  • V Offline
    V Offline
    voltron
    wrote on last edited by
    #1

    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 the requestPermission() call and eventually crashes. Am I doing something wrong?

    Tested on two devices (Andoid 7 and 10), Qt 6.4.1

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      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 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