@Override protected void onDestroy() { super.onDestroy(); if (rejoinChat != null) { rejoinChat.stop(); } if (restartChat != null) { restartChat.stop(); } if (messagingApi != null) { messagingApi.removeApiEventListener(this); messagingApi.disconnectApi(); } }