在安卓工作室中,在调试应用程序蓝牙LeGatt时,我得到了以下期望:



在Android Studio中,在调试应用程序BluetoothLeGatt时,我得到了以下异常:

从绑定程序存根实现中捕获了运行时异常。 java.lang.SecurityException:需要ACCESS_COARSE_LOCATION或ACCESS_FINE_LOCATION权限才能获得扫描结果 at android.os.Parcel.readException(Parcel.java:1684( at android.os.Parcel.readException(Parcel.java:1637( at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:678( at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered (BluetoothLeScanner.java:367( at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56( at android.os.Binder.execTransact(Binder.java:565(

如果您的目标平台是 Android 23 或更高版本,则清单和代码中缺少android.permission.ACCESS_FINE_LOCATION权限。

将该权限添加到清单.xml以及您的代码。

本页介绍了您需要了解的有关 Android 应用中权限的所有信息。

最新更新