本文整理汇总了Java中org.jivesoftware.smack.roster.RosterEntry.setName方法的典型用法代码示例。如果您正苦于以下问题:Java RosterEntry.setName方法的具体用法?Java RosterEntry.setName怎么用?Java RosterEntry.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.roster.RosterEntry
的用法示例。
在下文中一共展示了RosterEntry.setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSetContactName
import org.jivesoftware.smack.roster.RosterEntry; //导入方法依赖的package包/类
@Override
protected void doSetContactName(String address, String name) throws ImException {
Contact contact = getContact(address);
contact.setName(name);
Contact[] contacts = {contact};
notifyContactsPresenceUpdated(contacts);
// set name
try {
RosterEntry entry = mRoster.getEntry(JidCreate.bareFrom(address));
// confirm entry still exists
if (entry == null) {
return;
}
entry.setName(name);
}
catch (Exception e)
{
throw new ImException(e.toString());
}
}
示例2: updateRosterEntry
import org.jivesoftware.smack.roster.RosterEntry; //导入方法依赖的package包/类
public void updateRosterEntry(JID jid, String newName) {
if (!this.isConnected()) {
LOGGER.info("not connected");
return;
}
Roster roster = Roster.getInstanceFor(mConn);
RosterEntry entry = roster.getEntry(jid.toBareSmack());
if (entry == null) {
LOGGER.warning("can't find roster entry for jid: "+jid);
return;
}
try {
entry.setName(newName);
} catch (SmackException.NotConnectedException |
SmackException.NoResponseException |
XMPPException.XMPPErrorException |
InterruptedException ex) {
LOGGER.log(Level.WARNING, "can't set name for entry", ex);
}
}
示例3: renameContact
import org.jivesoftware.smack.roster.RosterEntry; //导入方法依赖的package包/类
public void renameContact(String remoteAccount, String newAlias) {
try {
Roster roster = Roster.getInstanceFor(mConnection);
RosterEntry entry = roster.getEntry(remoteAccount);
entry.setName(newAlias);
XmppServiceBroadcastEventEmitter.broadcastContactRenamed(remoteAccount, newAlias);
} catch (Exception exc) {
Logger.error(TAG, "Error while renaming contact: " + remoteAccount, exc);
}
}