'Requesting Android permissions in Qt 6
I am trying to convert a Qt 5 app to Qt 6. In Qt 5 we can request Android permissions as follows:
QStringList permissions;
//...
QtAndroid::PermissionResultMap resultHash = QtAndroid::requestPermissionsSync(permissions);
for (const auto &perm : permissions)
{
if(resultHash[perm] == QtAndroid::PermissionResult::Denied)
{
qDebug() << "Permission denied:" << perm;
return false;
}
}
What is the equivalent in Qt 6? Or is the only way to manually implement this using JNI?
Regards
Solution 1:[1]
There is no permission handling API in Qt6 yet. However, it is under making. You can follow the situation from QTBUG-90498. It looks like it is scheduled for Qt6.4 release which I assume will be due some time in the fall 2022. You can find a code review link from the bug report which might help you in writing your own implementation.
I would recommend you to take a look into QNativeInterface::QAndroidApplication::runOnAndroidMainThread which you can use for asynchronous calling on the Android UI thread.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | talamaki |
