private void sendChatState(ChatState state) { Connection connection = SparkManager.getConnection(); boolean connected = connection.isConnected(); if (connected) { Chat chat = connection.getChatManager().createChat(getParticipantJID(), null); try { ChatStateManager.getInstance(connection).setCurrentState(state, chat); lastNotificationSent = state; } catch (XMPPException e) { Log.error("Cannot send " + state + " chat notification"); } } }