xmpp send and receive message in android applicati

2019-08-04 05:03发布

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.

标签: android xmpp
1条回答
三岁会撩人
2楼-- · 2019-08-04 05:31

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);
查看更多
登录 后发表回答