【发布时间】:2022-01-23 03:16:31
【问题描述】:
问题:我想在 Android 上制作一个需要蓝牙功能的应用程序,但我不太确定需要哪些权限。我将退出此文档https://developer.android.com/guide/topics/connectivity/bluetooth/permissions,但措辞让我感到困惑。在我的应用程序 gradle 文件中,我的 targetSdk 和 compileSdk 都设置为 31,这将是 Android 12。我的 minSdk 设置为 23,但是这将是 Android 6.0。至少我知道我的应用程序需要能够扫描蓝牙设备、连接设备并与设备通信。我的应用不会从蓝牙扫描中获取位置。
至少我需要的权限如下所示:
<manifest>
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<!-- Needed only if your app looks for Bluetooth devices.
If your app doesn't use Bluetooth scan results to derive physical
location information, you can strongly assert that your app
doesn't derive physical location. -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<!-- Needed only if your app communicates with already-paired Bluetooth
devices. -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
...
</manifest>
这来自“目标 Android 12 或更高版本”下的链接网页,但我想知道我是否还需要遵守“目标 Android 11 或更低版本”部分,因为我的最低 Android SDK 是 Android 6.0。那么我是否适合遵循 Android 12 目标指令或 Android 11 或更低目标指令?
【问题讨论】:
标签: android bluetooth android-permissions