Dave Tolls wrote:For starters I'd stick some logging in there to try and trace what's going on.
The BluetoothAdapter should only send a FOUND for each device once, so logging might help to show whether that is the case or not.
Remove the check for whether the device is already in the list, since that should not be needed.
Also you should not have to manually get your android device to search. If you do that then yes, you may well get duplicates.
Can you register for the START and STOP events from the adapter as well? Log them just to track things.
That might give you some more info.
So, as you advised, I used logging, removed the check for device repetition and added the START and STOP action to the intent filter, but I'm getting the same results.
Here's the modified code
I tested it on Lollipop and Jelly Bean platform and on both I have to manually scan for devices, after which I'm getting proper logging messages, although, on Lollipop the devices are repeating, generating log message every time a device is added to the list, whereas on Jelly Bean one device is displayed only once.
Another thing that I don't understand is that the two conditions
and
are not being satisfied as I'm neither getting the log message nor anything on the TextView.