qt_add_android_permission

向目标可执行文件添加 Android 权限。

该命令在Qt6 软件包的Core 组件中定义,可以像这样加载:

find_package(Qt6 REQUIRED COMPONENTS Core)

此命令在 Qt 6.9 中引入。

简介

qt_add_android_permission(target NAME <permission-name> [ATTRIBUTES <name1> <value1> ...])

如果禁用了无版本命令,请使用qt6_add_android_permission() 代替。它支持与此命令相同的参数集。

说明

该命令为target 可执行文件添加 Android 权限。它可用于定义附加权限,或覆盖 Qt 模块设置的默认权限。

有关定义 Android 权限的更多信息,请参阅Qt 权限和功能

示例

qt_add_executable(myapp
    // ...
)
qt_add_android_permission(myapp
    NAME android.permission.BLUETOOTH_SCAN
    ATTRIBUTES
        minSdkVersion 31
        usesPermissionFlags neverForLocation
)
qt_add_android_permission(myapp
    NAME android.permission.ACCESS_COARSE_LOCATION
)

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.