Home > Mobile >  BLUETOOTH_CONNECT, BLUETOOTH_SCAN Missing permissions
BLUETOOTH_CONNECT, BLUETOOTH_SCAN Missing permissions

Time:12-22

enter image description here

There seems to be a problem with 'BLUETOOTH_CONNECT and 'BLUETOOTH_SCAN'. But I have already made a declaration.


`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" >


    <!-- 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 makes the device discoverable to Bluetooth
         devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

    <!-- Needed only if your app communicates with already-paired Bluetooth
         devices. -->
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

    <!-- Needed only if your app uses Bluetooth scan results to derive physical location. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- Include "neverForLocation" only if you can strongly assert that
             your app never derives physical location from Bluetooth scan results. -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />

    <!-- Not needed if you can strongly assert that your app never derives
         physical location from Bluetooth scan results and doesn't need location
         access for any other purpose. -->
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
    <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>


</manifest>`

This is the whole of androidmanifest.xml. I don't know why there is an error in the code. Help me.

CodePudding user response:

The permissions BLUETOOTH_CONNECT and BLUETOOTH_SCAN are so called runtime permissions. It is correct to declare them in your manifest, but you also need to request them at runtime. See the Bluetooth Permissions Guide for informations on all permissions needed for the different Android versions.

The Guide about requesting permissions explains in detail what you need for these runtime permissions.

CodePudding user response:

BLUETOOTH_CONNECT and BLUETOOTH_SCAN are runtime permissions. Therefore, you must not only declare these permissions in the manifest file, but also obtain the user's consent before using these functions.

  • Related