Android Question AsynchStreams doesn't find all devices

DickD

Active Member
Licensed User
I am trying to implement the Asynchstreams/ChatActivity sample from the B4A forum. I've found that this does not find all available devices. Sometimes it finds a few or none at all. I am sure that all test platforms have "Make device discoverable" clicked and it is within the time limit that DISCOVERABLE_DURATION is set to.

If I switch over to manually scanning for devices in the Bluetooth Settings tool all devices do show up and much more quickly than in the app. This has been tested on phones and tablets running Android 4.2, 4.4 and 6.0. All results are consistent across the board.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
AsyncStreams has nothing to do with finding devices. AsyncStreams reads and writes data to an established connection.

There is a single API in Android for searching devices and this is how BluetoothAdmin.StartDiscovery is implemented. There is no way to make it faster.

Maybe the other screen also shows previously paired devices (similar to Serial.GetPairedDevices).
 
Upvote 0

DickD

Active Member
Licensed User
AsyncStreams has nothing to do with finding devices. AsyncStreams reads and writes data to an established connection.

There is a single API in Android for searching devices and this is how BluetoothAdmin.StartDiscovery is implemented. There is no way to make it faster.

Maybe the other screen also shows previously paired devices (similar to Serial.GetPairedDevices).
I just retested this and made sure there were no paired devices on any of the three units. All the devices were still within their discoverable time limit and all three showed only 1 other available device, each a different one: A showed B available, B showed C and C showed A!!!
AsyncStreams has nothing to do with finding devices. AsyncStreams reads and writes data to an established connection.

There is a single API in Android for searching devices and this is how BluetoothAdmin.StartDiscovery is implemented. There is no way to make it faster.

Maybe the other screen also shows previously paired devices (similar to Serial.GetPairedDevices).
You may be right about showing previously paired devices although I really don't know how they got paired. Is there an example of displaying paired devices and can I unpair then in code?

Also, I found some interesting things that may explain my confusion. I discovered that Bluetooth on my Samsung S6 Android 6.0.1 phone is always visible. There is no countdown timer which turns it off. Also, on my old $50 phone which is very slow I think the process is actually timing out before it can show all available devices.
 
Upvote 0
Top