xmpp在android应用程序中发送和接收消息 [英] xmpp send and receive message in android application

查看:30
本文介绍了xmpp在android应用程序中发送和接收消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个短信应用程序.我可以使用函数 sendMessage("subject" , "to"); 从我的应用程序发送消息.我需要知道如何接收从另一端发送的消息.我需要获取该数据并在我的应用程序的 textview 中显示数据.我怎么能做到这一点.我怎么能做到这一点.请指导我.

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.

提前致谢.

推荐答案

这将帮助您:

 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);

这篇关于xmpp在android应用程序中发送和接收消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆