I have an android app with min SDK 19, look at in my scenario:
- click on button;
- BLE scan callback scans around BLE devices and if it find specific device (i have special MAC address, sends to me; 3.returned object has ScannedBleDevice type, i get it and run mGattCallback.connect(...);
- i connect to device perfectly and onConnectionStateChanged equals to SUCCESS;
- i write a characteristic then read another one;
- i update Room data base table depend on recieved data from ble device;
- imageviews and textviews on active view Update simultaneously because i use livedata type on room data tables;
- exactly after update view, i disconnect from BLE Device without receive any onConnectionStateChange callbacks.
why? i don't know. please help me... i found somethings in these links but not exactly what i want:
Android: Catching BLE Connection Fails/Disconnects?
Android - BLE connection parameter and Storing BLE sensor data in SQLite Database