我已经在堆栈上经历了相关的问题,但是都是徒劳的。我没有在邀请侦听器中得到回调。任何帮助将不胜感激。
MultiUserChatListener
MultiUserChatManager.getInstanceFor(connection).addInvitationListener(new InvitationListener() {
@Override
public void invitationReceived(XMPPConnection conn, MultiUserChat room, String inviter, String reason, String password, Message message) {
String nickname = AppSharedPereference.getInstance(mContext).getUserName();
try {
mchat.join(nickname);
} catch (SmackException.NoResponseException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
}
});
}
发送邀请方法
public void sendInvites(ArrayList<ContactData.Usercontactsdetail> usercontactsdetail) {
try {
for (int i = 0; i < usercontactsdetail.size(); i++) {
String userID = usercontactsdetail.get(i).getContactid();
String user = userID + "@" + connection.getHost();
mchat.invite(user,
userID + "_user");
}
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}finally {
usercontactsdetail = null;
}
try {
mchat.sendMessage("New group created");
} catch (SmackException.NotConnectedException e1) {
e1.printStackTrace();
}
}