I am developing in Android for BLE. My BLE device will broadcast for different name , so I need to continue re-scan Android.
I create a Runnable
to stop and start scan like the following. When I call mHandler.post(monitorDevice);
, it will start the Runnable
.
final Runnable monitorDevice = new Runnable() {
@Override
public void run() {
scanLeDevice(false);
scanLeDevice(true);
mHandler.postDelayed(this,3000);
}
};
The code of scanLeDevice
is like the following:
public void scanLeDevice(final boolean enable) {
// TODO Auto-generated method stub
if(enable){
mScanning = true;
mBluetoothAdapter.startLeScan(mLeScanCallback);
}else {
mScanning = false;
mBluetoothAdapter.stopLeScan(mLeScanCallback);
}
}
I can see the scan result in the log at the begin. But after about 10~15 minute , the logcat show the following log , and I can not seen any scan result.
startLeScan(): null
D/BluetoothLeScanner﹕ onClientRegistered() - status=0 clientIf=5
Does someone has this problem ? Thanks in advance!!!