我正在尝试设置XMPP聊天应用程序。现在我可以在gmail和gmail之间发送消息。我想输入通知,例如用户输入的内容或用户正在输入,,, 就像那样。我正在使用主类和Message侦听器类。
主要类
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");
}
消息监听器类
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());
}
}
}
每当user@gmail.com开始在我们的对话中输入内容时,我需要在Log中收到一条消息。但它不会来。它正在发送消息..
我在堆栈溢出中尝试了另一个答案。 How to know Typing Status in XMPP openfire using Smack
但是从这一点上我也没有得到解决方案。请帮帮我。