xmpp send and receive message in android application

时间秒杀一切 提交于 2019-12-11 10:36:33

问题


I am working on a sms application. I am able to send a message from my application using the function sendMessage("subject" , "to");. I need to know how to receive the message sent from the other end. I need to get that data and display the data in textview in my application. How can i achive that. How can i achive that. Please guide me.

Thanks in aadvance.


回答1:


this will help you:

 PacketFilter filter = new MessageTypeFilter(Message.Type.chat);

                // Listener for incoming message from any user

                connection.addPacketListener(new PacketListener() {
                    public void processPacket(Packet packet) {
                        final Message message = (Message) packet;
                        if (message.getBody() != null) {
                            fromName = StringUtils.parseBareAddress(message
                                    .getFrom());
                            Log.i("XMPPClient", "Got text [" + message.getBody()
                                    + "] from [" + fromName + "]");     


                                    }
                                }
                            });

                        }
                    }
                }, filter);


来源:https://stackoverflow.com/questions/9596136/xmpp-send-and-receive-message-in-android-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!