Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Openfire:我如何知道服务器中存储的哪些用户是我的设备联系人?_Android_Openfire_Asmack - Fatal编程技术网

Android Openfire:我如何知道服务器中存储的哪些用户是我的设备联系人?

Android Openfire:我如何知道服务器中存储的哪些用户是我的设备联系人?,android,openfire,asmack,Android,Openfire,Asmack,我正在为Android开发一个简单的聊天工具。我正在阅读Openfire ante asmack API。显然,用户应该只看到存储在其设备中的联系人,因此:我如何知道存储在服务器中的哪些联系人是我的设备联系人?或者,我如何为联系人分配其设备中的联系人?我已经看到它可以在管理控制台中完成,但是通过代码?这是我开始开发它所需要知道的最后一件事 提前感谢。试试这个: // Create the configuration for this new connection ConnectionConfig

我正在为Android开发一个简单的聊天工具。我正在阅读Openfire ante asmack API。显然,用户应该只看到存储在其设备中的联系人,因此:我如何知道存储在服务器中的哪些联系人是我的设备联系人?或者,我如何为联系人分配其设备中的联系人?我已经看到它可以在管理控制台中完成,但是通过代码?这是我开始开发它所需要知道的最后一件事

提前感谢。

试试这个:

// Create the configuration for this new connection
ConnectionConfiguration config = new ConnectionConfiguration("jabber.org", 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);

Connection connection = new XMPPConnection(config);
// Connect to the server
connection.connect();
// Log into the server
connection.login("danilodeveloper", "password", "SomeResource");
// getting the Openfire contacts that danilodeveloper has
Roster roster = connection.getRoster();
// the contacts
Collection<RosterEntry> entries = roster.getEntries();
//创建此新连接的配置
ConnectionConfiguration config=新的ConnectionConfiguration(“jabber.org”,5222);
config.setCompressionEnabled(true);
config.setaslauthenticationenabled(true);
连接=新的XMPPConnection(配置);
//连接到服务器
connection.connect();
//登录到服务器
登录(“danilodeveloper”、“密码”、“SomeResource”);
//获取danilodeveloper拥有的Openfire联系人
花名册=connection.get花名册();
//联系人
集合条目=花名册.getEntries();
通过这些条目(例如entrie.getUser()),您可以将Openfire联系人与设备联系人进行比较


干杯

谢谢danilo,但是,我可以使用什么参数来比较Operfire联系人和设备联系人?我的意思是,Openfire中的联系人没有电话号码,用户名也可能不一样。我忘了说我正在使用Openfire的内部BD。我可以使用MySQL吗?嗨@luis,你可以通过Smack API将电话号码存储在Openfire上(我不记得是什么方法,但应该很简单),你可以使用[link](getProperty方法)进行检索。@luis,关于MySQL,你应该在应用程序投入生产时使用,你将获得最佳性能,你可以使用集群。使用内部BD进行开发。@danilodeveloper我尝试了你的答案,但它返回了我的朋友列表。如果我想检查没有添加到我的花名册中的联系人,该怎么办。比如whatsapp联系人。whatsapp检测哪个联系人有whatsapp应用程序,如果有,我们可以向他/她发送消息。否则请,,