Skip to content Skip to sidebar Skip to footer

Startlescan Returns False

BluetoothAdapter's method startLeScan returns false sometimes during scanning BLE devices.Hence,I am facing issues in my application.I am using the newer method startScan(ScanCallb

Solution 1:

If you look at the source code for startLeScanhere, you will see that there are several things that can cause the return code to be false:

  1. A null callback ha been provided
  2. A scan has already been started by a client using the same callback
  3. The device doesn't support Bluetooth LE
  4. An internal RemoteException occurs.
  5. An internal call to android.bluetooth.IBluetoothGattregisterClient fails.

Since this works sometimes, the problem is probably not 1 or 3. You can check to see if it is 4 by seeing if an error shows up in LogCat when this happens.

Item 2 above is a good candidate. Are you sure the code is always stopping scanning properly? You might want to log each time you start and stop scanning and make sure you never see two starts in a row.

If the problem is none of the above, that leaves possibility 5, which would indicate an issue with the bluetooth chip or driver in the ROM. If this is the case, you should be able to run the same code on a different device and see the problem go away.

Post a Comment for "Startlescan Returns False"