Jasonchenlijian / FastBle

Android Bluetooth Low Energy (BLE) Fast Development Framework. It uses simple ways to filter, scan, connect, read ,write, notify, readRssi, setMTU, and multiConnection.
Apache License 2.0
5.28k stars 1.22k forks source link

退出app后就会断开连接,不知道哪里出了问题 #558

Open jxxp opened 1 year ago

jxxp commented 1 year ago

没有调用, BleManager.getInstance().disconnectAllDevice();BleManager.getInstance().destroy(); 断开连接的任务方法。

@Override
protected void onDestroy() {
    super.onDestroy();

// BleManager.getInstance().disconnectAllDevice(); // BleManager.getInstance().destroy(); Log.d("MainActivity", "onDestroy"); }

Wheats commented 1 year ago

断开连接

1.如果没有主动断开连接,想保活。试试把连接放在服务里,用startForegroundService 和Notification搭配使用。

2.如果连接上,一直有数据交互,切换后台不会断开,不会杀死。