7

I am trying to setup an XMPP chat application. Right now I am able to send messages between gmail to gmail. I want typing notification such as user typed something or user is typing,,, Like that. I am using a main class and a Message listener class.

Main Class

public class XMPPChatDemoActivity extends Activity {

    //Object of Custom class
    MessageListener messageListener = new MessageListenerImpl();

    private void setConnection(XMPPConnection connection) {
        this.connection = connection;

        ChatManager chatmanager = connection.getChatManager();
        Chat newChat = chatmanager.createChat("user@gmail.com", messageListener);
        try {
            newChat.sendMessage("Howdy!");
        }
        catch (XMPPException e) {
            System.out.println("Error Delivering block");
        }

Message listener class

public class MessageListenerImpl implements MessageListener , ChatStateListener{

    @Override
    public void stateChanged(Chat arg0, ChatState arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void processMessage(Chat arg0, Message arg1) {
        // TODO Auto-generated method stub

        System.out.print("here");

        if (ChatState.composing.equals(arg1)) {
            Log.d("Chat State",arg0.getParticipant() + " is typing..");
        } else if (ChatState.gone.equals(arg1)) {
            Log.d("Chat State",arg0.getParticipant() + " has left the conversation.");
        } else {
            Log.d("Chat State",arg0.getParticipant() + ": " + arg1.getFrom());
        }

    }

}

Here whenever user@gmail.com starts to type something in our conversation I need to get a message in Log. But its not coming. It is sending messages..

I tried another answer in stack-overflow. How to know Typing Status in XMPP openfire using Smack

But from this also I didn't get a solution. Please help me out.

Community
  • 1
  • 1
Aneez
  • 205
  • 3
  • 12

0 Answers0