Android Question Bluetooh device found being called several times

JTmartins

Active Member
Licensed User
Longtime User
Hi everyone,

In my "quest" to create my own obd reader, I found a little problem, that is driving me nuts.

OBD reading is is working perfectly and so far no problems with that with several protocols. However, while at the stage of creating a setings section for the app I decided to make this as easy for the user, as many of them do not actually know how to enable bluetooth, paring, etc.

So bluetooth admin to the rescue...

My Idea is to limit the list to show to the user to a list of bluetooth devices in a certain range (inside the car), as some days ago, with 2 cars, I could actually connect to a car nearby. So RSSI was need and RSSI is working. A range of -77 db seems to be OK, and nothing with a lower rssi is showed in the list (although being detected)

Now the problem is that when I ran the app for the first time, all is OK and the list of available devices in the range I want is showed. In the listview that apears after the search finishes you can touch to connect serial, and after that is reverts to the first activity. (or shows an error if it cannot serial connect and returns again to the first activity)

Now if you launch the search activity a second time (pressing launch again), the admin_devicefound is called twice every time a device is found...if you launch again admin_devicefound is called 3 times every time a device is found...etc. (There is a counter that shows that)

And I can't understand why this is happening, so Im pretty sure I'm doing something wrong.

I attach a small sample of the running code wich reproduces the problem.

Many thanks to any help, and I'm sorry for variable names which are not in English, althoug on screen text is in english.

JM
 

Attachments

  • listviewobd.zip
    33.5 KB · Views: 162
Last edited:

JTmartins

Active Member
Licensed User
Longtime User
*** SOLVED ****

Private BtAdmin As BluetoothAdmin, has to be defined in Process_Globals, otherwise it will be instantied every time the search activity starts...I don't know how I've missed that.
 
Upvote 0
Top