本文整理汇总了Java中org.jivesoftware.smack.roster.Roster.createEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.createEntry方法的具体用法?Java Roster.createEntry怎么用?Java Roster.createEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.roster.Roster
的用法示例。
在下文中一共展示了Roster.createEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addContact
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void addContact(String jidString)
throws SmackException.NotLoggedInException, InterruptedException,
SmackException.NotConnectedException, XMPPException.XMPPErrorException,
SmackException.NoResponseException, XmppStringprepException {
Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
if (!roster.isLoaded()) {
roster.reloadAndWait();
}
BareJid jid = JidCreate.bareFrom(jidString);
String name = XMPPUtils.fromJIDToUserName(jidString);
String[] groups = new String[]{"Buddies"};
roster.createEntry(jid, name, groups);
roster.sendSubscriptionRequest(jid);
}
示例2: addBuddy
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void addBuddy(String user) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException {
Roster roster = Roster.getInstanceFor(connection);
roster.setSubscriptionMode(SubscriptionMode.accept_all);
// jid: String, user: String, groups: String[]
// null groups
roster.createEntry("[email protected]", "grog", null);
}
示例3: createEntry
import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void createEntry(String user, String name) throws Exception {
// FileLog.e("Test", String.format("Creating entry for buddy '%1$s' with name %2$s", user, name));
Roster roster =Roster.getInstanceFor(connection);
roster.createEntry(JidCreate.bareFrom(user), name, null);
}