0

i am developing a simple chat application.

i am able to chat with multiple users simultaneously, but my problem is that i am not able to show "is typing..." status to the other user.

i referred to this link How to get typing status notification in XMPP but dint help :(

any help will be appreciated.

     my sample code:
            String text = textMessage.getText().toString();
            String to = recipient.getText().toString();
            Log.i("Composing=>", "Sending text " + text + " to " + to);
            Message msg1 = new Message(to, Message.Type.chat);

            msg1.setFrom("user1@192.168.0.98"); // my id

            MessageEventManager event=new MessageEventManager(connection);
              //recipient id
            event.sendComposingNotification("tech1@192.168.0.98",msg1.getPacketId());        

if i am chatting in browser then it working fine and i am able to see the status"is typing" when the other user is typing in his window.

Community
  • 1
  • 1
Mohit
  • 505
  • 8
  • 31
  • XEP-22 Message Events is obsolete. Try using XEP-85 Chat State Notifications instead.For the relevant Smack API see https://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/smackx/chatstates/ChatStateManager.html – Flow Sep 10 '14 at 13:25

2 Answers2

0

Hi I have done this by this.

Your code is fine for sending a typing indication. You need to register a indicator at recipient end.

sXmppConnection.getChatManager().addChatListener(new ChatManagerListener() {

                    @Override
                    public void chatCreated(Chat arg0, boolean arg1) {

                        Log.d("chatCreated",""+arg1);

                        arg0.addMessageListener(new MessageListener()
                        {

                            @Override
                            public void processMessage(Chat arg0, Message arg1) 
                {Log.d("TYpe Stat", arg0.getParticipant()+" is typing......");
                            }
                        });

                    }
                });
shailesh
  • 1,783
  • 2
  • 17
  • 26
0

Just add ChatStateManager after ChatManager intalization

chatManager =  ChatManager.getInstanceFor(getXmpptcpConnection());
ChatStateManager.getInstance(getXmpptcpConnection());

then you need add ChatStateListener during createChat(to,chatMesageListener)

chatManager.createChat(message.getTo(), chatMessageListener).sendMessage(message);

private ChatStateListener chatMessageListener = new ChatStateListener() {

        @Override
        public void stateChanged(Chat chat, ChatState state) {
            //State Change composing,active,paused,gone,etc
            Log.d(TAG, "ChatStateListener:::stateChanged -> " + chat.toString() + " \n -> " + state.toString());
        }

        @Override
        public void processMessage(Chat chat, Message message) {
            //Incoming Message
            Log.d(TAG, "ChatStateListener:::processMessage -> " + chat.toString() + " \n -> " + message.toString());
        }
    };
dastan
  • 892
  • 10
  • 17