android Bluetooth low energy (BLE) disconnect / reconnect -


the app activity displays list of available ble devices , connects selected (i see notifications etc). code:

private static bluetoothadapter madapter=null; if(madapter == null); madapter = bluetoothadapter.getdefaultadapter(); madapter.startlescan((bluetoothadapter.lescancallback)mcontext); 

it gives entry of 1 device (as expected). however, cannot disconnect. connection seams remain when close app. led indicating connection stays on , on next run of app list of available devices emply - disconnect had restart device or phone.

i've tried system. exit(0) , private static bluetoothgatt mgatt; mgatt.disconnect(); , in android device monitor stoping app instance (was there after buttons main activity, way - why there - unregistered broadcast receiver?). still led of device on , on next app start list of available devices empty (and no messages displayed on screen - notifications etc).

how reset ble connection properly? if more app code needed add it.

it's not entirely clear description happening. notifications see? how building , managing device list? under conditions should led light turn on on device?

regardless of this, should calling mgatt.close() in ondestroy() or onpause() if aren't calling before.

whether pressing button finishes app depends on how set , won't mean there resource hasn't been released it's worth checking. it's more service has been left running unregistered broadcast receiver think gets handled system (this doesn't mean shouldn't deregister receivers).


Comments