8

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!!!

Wun
  • 6,211
  • 11
  • 56
  • 101
  • Did you solve the problem? I have the same issue. And after a period, call startLeScan() will block 10 seconds, and return false. – codezjx Jul 16 '15 at 06:37
  • Was this ever solved? same issue, it will work fine for a time then just start outputting that over and over again – Joe Maher Nov 23 '15 at 12:18
  • I had similar issue, found the solution on SO. You'll see there a refresh of the cache related to connections, yet it solved other items as above (scanning). http://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android – Oren May 12 '16 at 11:53
  • http://stackoverflow.com/questions/24568932/blutooth-le-scan – Leo supports Monica Cellio May 31 '16 at 17:08

0 Answers0