stop Server
Stops the GATT server and BLE advertising.
This method performs a clean shutdown of the GATT server:
Closes the GATT server, which disconnects all connected devices
Stops BLE advertising, making the device no longer discoverable
Clears the server reference
After calling this method:
All connected central devices will be disconnected
The device will no longer appear in BLE scans
Any pending notifications will not be delivered
The notificationEnabledDevices set is NOT automatically cleared (devices are removed individually via the disconnect callback)
This method is safe to call multiple times and when the server is not running.
Lifecycle Recommendation
Always call this method in your Activity's onDestroy() or when your service is stopped to ensure proper resource cleanup:
override fun onDestroy() {
super.onDestroy()
gattServer.stopServer()
}See also
Throws
if required Bluetooth permissions are not granted