android bluetoothadapter.startLeScan,按UUID过滤

本文介绍了android bluetoothadapter.startLeScan,按UUID过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 startLeScan(UUID[] serviceUuids, LeScanCallback callback) 方法扫描 BLE 设备,现在我有一个 UUID,它是一个 16 位的值,例如,00000000-0000-1000-8000-00805F9B34FB.

(I want to scan BLE device with the startLeScan(UUID[] serviceUuids, LeScanCallback callback) method, now I have a UUID, it's a 16-bits value, for example, 00000000-0000-1000-8000-00805F9B34FB.)

如何在startLeScan方法中使用UUID,我是这样写的,

(How can I use the UUID in startLeScan method, I write like this,)

UUID[] uuid = new UUID[1]; uuid[0] = UUID.fromString("00000000-0000-1000-8000-00805F9B34FB");
mBluetoothAdapter.startLeScan(uuid, mLeScanCallback);

但最后我什么也扫描不了.我该如何解决这个问题.

(But finally I can scan nothing. How can I resolve this problem.)

推荐答案

我和你的方法一样,我在 AndroidManifest.xml 文件中添加了如下权限:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

希望能帮到你.

这篇关于android bluetoothadapter.startLeScan,按UUID过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

转载于:android bluetoothadapter.startLeScan,按UUID过滤 - IT屋-程序员软件开发技术分享社区

猜你喜欢

转载自blog.csdn.net/weixin_42602900/article/details/125988460