【发布时间】:2015-09-30 07:44:09
【问题描述】:
我有与低功耗蓝牙相关的项目。我扫描附近的所有 BLE 设备并通过很多不同的图标显示到屏幕上。我没关系。但我想检查是否扫描不是 BLE 设备,我会显示一条消息“未找到 BLE 设备”。我不知道检查 NULL BLE 设备。也许你知道!?
这是我的一些代码:
private BluetoothAdapter mBluetoothAdapter;
final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();
mBluetoothAdapter.startLeScan(mLeScanCallback);
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice arg0, int arg1, byte[] arg2) {
// TODO Auto-generated method stub
runOnUiThread(new Runnable() {
@Override
public void run() {
//TODO add device to screen
});
}
};
【问题讨论】:
-
澄清一下,您是否需要检查在 LeScan 中获得的 BluetoothDevice 是否不是 LE 设备(!),或者您是否要检查根本没有调用 onLeScan 的情况?
-
我想检查一下 onLeScan 根本没有被调用过的情况。
标签: android bluetooth bluetooth-lowenergy