Android Question bluetooth, phone and distance


New Member
Hi everycoders ;-),

I try to realize an application for android (iOS in future surely) but have little difficulties.

The idea is to discover phone in my family (using BLEManager library because using GPS is too bad on my test [few meters errors...]) which all have the program installed on. For do that I know I need to make them always discoverable :

Intent1.Initialize("BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE", "")

and use that for found device

Sub BLuE1_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
    Log("Name= " & Name & ", ID= " & Id & ", RSSI= " & RSSI & ", AD= " & AdvertisingData)   
End Sub

All is OK at this point but I need to limit (or calcul) distance between my phone and bluetooth search, so do you find it's possible and, if yes, how could I do that ? Or maybe I could estimate distance with bluetooth data but I don't know how ?

Thanks all for helping


B4X founder
Staff member
Licensed User
Longtime User
You are confusing classic Bluetooth and BLE.

You can use BLEPeripheral to advertise some information and detect it with BLEManager. You can also calculate the distance however it will be very inaccurate.

If the devices are connected to the same network then you can use UDP broadcasting to detect other devices. This will work better.
Upvote 0