sockets - Android Bluetooth Connection between two devices programmatically Fails -


i trying connect devices via bluetooth. when hit search button good. when click device detected devices list paired correctly. when click desired device paired devices list connect, firstly connected after ~5 seconds disconnect , stay paired.also socket closes...this get: enter image description here

the code : here

firstly connected after ~5 seconds disconnect , stay paired.

if device bluetooth low energy device, well, bluetooth le designed be. unlike classical bluetooth, bluetooth le keep connection short period of time. after data exchange complete, current connection end immediately. connection established again when there data exchange next time.

if problem isn't caused bluetooth designing should caused code itself. in post can see:

the application may doing work on main thread.

what means code taking long process , frames being skipped because of it, maybe because of heavy processing doing @ heart of application or db access or other thing causes thread stop while.

how fix it?

the best way processing no matter how small or big in thread separate main ui thread. comprehensive explanation here.


Comments