如何在 smack 4.2.0 中获取 BareJid
How to get a BareJid in smack 4.2.0
我使用Roster 通过Roster 的方法createEntry(BareJid user, String name, String[] groups) 创建了Roster Entry,但我不知道如何获得BareJid。有人能帮我吗?这是我的代码,我的 userJid 是一个字符串:
Roster roster = XmppConnectionManager.getInstance().getRoster();
if (roster != null) {
try {
// String[] jids = userJid.split("@");
roster.createEntry(userJid, nickname, null);
} catch (SmackException.NotLoggedInException e) {
e.printStackTrace();
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
Log.w(TAG,"roster is null");
}
刚刚被Google找到,有一个JID助手class JidCreate
:
JidCreate.bareFrom(userJid)
我使用Roster 通过Roster 的方法createEntry(BareJid user, String name, String[] groups) 创建了Roster Entry,但我不知道如何获得BareJid。有人能帮我吗?这是我的代码,我的 userJid 是一个字符串:
Roster roster = XmppConnectionManager.getInstance().getRoster();
if (roster != null) {
try {
// String[] jids = userJid.split("@");
roster.createEntry(userJid, nickname, null);
} catch (SmackException.NotLoggedInException e) {
e.printStackTrace();
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
Log.w(TAG,"roster is null");
}
刚刚被Google找到,有一个JID助手class JidCreate
:
JidCreate.bareFrom(userJid)