Not able to get LastActivity of a jabberId

心已入冬 提交于 2019-12-04 16:42:44

Have you added other jabber id as your roster. If not try adding them then check. If you are using ejabbered then you can manually add roster from their admin panel for testing. I used this code snippet to add roster--

Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);

                    String number = datacollection.get(i).getNo().replace("+", "");
                    String jid = number + "@localhost";

                    Collection<RosterEntry> entries = roster.getEntries();
                    for (RosterEntry entry : entries)
                    {
                        System.out.println(entry);
                        if (entry.getUser().equals(jid))
                        {
                            rosterAlreadyAdded = true;
                            if (entry.getType() != RosterPacket.ItemType.both)
                            {
                                // Create a presence subscription packet and send.
                                Presence presencePacket = new Presence(Presence.Type.subscribe);
                                presencePacket.setTo(jid);
                                connection.sendStanza(presencePacket);
                            }

                        }

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