【发布时间】:2017-04-25 09:39:24
【问题描述】:
我对 Android 的 BLE 扫描有问题,我没有找到找到的扫描设备的全名,我只收到第一个字母你知道如何解决这个问题吗?
我正在使用支持 BLE 的 7.0 Nougat 设备
这是我的代码的一部分:
mBluetoothScanner = mBluetoothAdapter.getBluetoothLeScanner();
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER)
.build();
if (Build.VERSION.SDK_INT >= 21) {
mScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
messageLog.error("onScanResult");
BluetoothDevice btDevice = null;
if (Build.VERSION.SDK_INT >= 21) {
btDevice = result.getDevice();
messageLog.error("btDevice : " + btDevice.getName() + "|" + btDevice.getAddress() + "|" + Arrays.toString(btDevice.getUuids()));
}
if (btDevice != null && btDevice.getName() != null && !isInDeviceList(btDevice))
mDeviceList.add(btDevice);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
}
@Override
public void onScanFailed(int errorCode) {
Log.e("Scan Failed", "Error Code: " + errorCode);
}
};
}
使用 btDevice.getName() 我只能扫描设备的第一个字母,这是我的错还是来自 Android BLE API?
【问题讨论】:
标签: android embedded bluetooth-lowenergy