ChatStateListener无法正常工作

时间:2015-07-31 16:36:42

标签: android chat smack asmack

实施smack API,现在尝试获取聊天状态,例如用户是ComposingPaused等。到目前为止我做了什么

public class IncomingChatListener implements  ChatMessageListener, ChatStateListener {

        @Override
        public void stateChanged(Chat chat, ChatState state) {
            Log.d("-----","into chat state");
            if (ChatState.composing.equals(state)) {
                Log.d("Chat State",chat.getParticipant() + " is typing..");
            } else if (ChatState.gone.equals(state)) {
                Log.d("Chat State",chat.getParticipant() + " has left the conversation.");
            } else {
                Log.d("Chat State",chat.getParticipant() + ": " + state.name());
            }
        }
public void processMessage(Chat chat, Message message) {
.......
......

}

当用户输入时,我发送的状态如下:

ChatStateManager.getInstance(connection).setCurrentState(ChatState.composing, myChat);

问题是stateChanged函数永远不会被调用,而是在processMessage函数中收到了像composing等..的chatStatus数据包。

如何在stateChanged函数中收到它?

0 个答案:

没有答案