AnsweredAssumed Answered

ChatStateListener doesn't work

Question asked by Quan Tran on Nov 26, 2015
Latest reply on Oct 7, 2016 by DastanIqbal

Hi guys,

I'm using Smack 4.1 for Android application. I want to using the ChatStateListener to detect typing status. But i got nothing in stateChanged. But when I try use other Xmpp app, it can detect typing status.

Here is my code

public class CustomMessageListener implements ChatMessageListener,ChatStateListener {
    private Context context;


    public CustomMessageListener(Context context) {
        this.context = context;
    }
    @Override
    public void processMessage(Chat chat, Message message) {
        Log.d("XMPP",message.toXML().toString());
        if (message.getBody() != null) {
            // do somthing
        }
    }


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




And I always set the typing satus when message editor on changed. But why as I see the stateChanged never raise. Please help me.

Thanks

Outcomes