本文介绍了蓝牙低能量的扫描失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在开发将使用蓝牙低耗能的应用程序。
我使用下面的链接,
http://developer.android.com/samples/BluetoothLeGatt/src/com.example.android.bluetoothlegatt/DeviceScanActivity.html
我不能够扫描周围的BLE装置。
要扫描设备,
mBluetoothAdapter.startLeScan(mLeScanCallback);
私人BluetoothAdapter.LeScanCallback mLeScanCallback =新BluetoothAdapter.LeScanCallback()
{
@覆盖
公共无效onLeScan(最终BluetoothDevice类设备,INT RSSI,byte []的scanRecord)
{
runOnUiThread(新的Runnable(){
@覆盖
公共无效的run()
{
mLeDeviceListAdapter.addDevice(设备);
mLeDeviceListAdapter.notifyDataSetChanged();
}
});
}
};
解决方案
我有同样的问题,请将这些权限添加到您的清单
<使用-权限的Android:名称=android.permission.BLUETOOTH/>
<使用-权限的Android:名称=android.permission.BLUETOOTH_ADMIN/>
I am currently developing an application that will use Bluetooth Low Energy.
I am using the following link,
I am not able to scan the surrounding BLE devices.
To scan device,
mBluetoothAdapter.startLeScan(mLeScanCallback);
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback()
{
@Override
public void onLeScan(final BluetoothDevice device, int rssi,byte[] scanRecord)
{
runOnUiThread(new Runnable() {
@Override
public void run()
{
mLeDeviceListAdapter.addDevice(device);
mLeDeviceListAdapter.notifyDataSetChanged();
}
});
}
};
解决方案
I had the same problem please add these permissions to your manifest
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
这篇关于蓝牙低能量的扫描失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!