Skip to content
Advertisement

Android BLE Scan Callback is not called after scanning for BLE devices

I’m creating an Android app that scans all nearby BLE (Bluetooth Low Energy) devices using Android Studio.

I think I have implemented all these documentations:

  1. https://developer.android.com/guide/topics/connectivity/bluetooth/ble-overview
  2. https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#java
  3. https://developer.android.com/guide/topics/connectivity/bluetooth/setup#java
  4. https://developer.android.com/guide/topics/connectivity/bluetooth/find-ble-devices

But as you can see in the log below, (the problem) there are no BLE devices scanned by the app.

Here are the logs in the logcat:

Log

I think it could happen because the BLE scan callback is not called (no BLE scan callback in the log).

So my question is what is the solution for my code? Did I miss coding something?

Here is my code

AndroidManifest.xml:

JavaScript

BluetoothHelper.java:

JavaScript

HomeActivity.java:

JavaScript

UPDATE

I added this code into android10BluetoothPermission() function in BluetoothHelper.java class but still didn’t work.

JavaScript

Advertisement

Answer

Finally, I have modified my code so the code now is working. Here it is:

ScanAndPairActivity.java (I’m creating a new activity for scanning and pairing BLE devices):

JavaScript

Thank you everyone for your help and special thanks to Isaidamier for showing me the example app here.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement