“MultiUserChat.addInvitationListener” not being called

爱⌒轻易说出口 提交于 2020-01-04 14:19:04

问题


I am working on a GroupChat process. I have successfully sent the invitation and using PSI i have received this invitation. But M unable to invoke my own "MultiUserChat.addInvitationListener". I have done this many ways but in-vain. Here is one of my attempt.

ProviderManager pm = ProviderManager.getInstance();
pm.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new MUCUserProvider());
MultiUserChat.addInvitationListener(mXmppConnection, MyClass.this);

And doing "MyClass extends Activity implements InvitationListener"

@Override
public void invitationReceived(final Connection conn,final String room, final String inviter, String reason, String password, Message message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(MyClass.this);

    builder.setTitle("Room Invitation");
    builder.setMessage(inviter + " sent you an invitation to join GroupChat saying  \""+reason+" \". \n Do you want to join "+inviter+"?");
    builder.setPositiveButton("Accept", new DialogInterface.OnClickListener() {

        // Joining Room
        @Override
        public void onClick(DialogInterface dialog, int which) {

            try {
                MultiUserChat   multiUserChat = new MultiUserChat(conn, room);
                multiUserChat.join(myNickName);
                if(multiUserChat.isJoined()){
                            dialog.cancel();
                }

            } catch (XMPPException e) {
                e.printStackTrace();
            }
        }
    });
    builder.setNegativeButton("Decline", new DialogInterface.OnClickListener() {
        // Declining Room Invitation
        @Override
        public void onClick(DialogInterface dialog, int which) {
            MultiUserChat.decline(conn, room, inviter, "I'm busy right now");
            dialog.cancel();
        }
    });
    builder.show();

}

来源:https://stackoverflow.com/questions/27125574/multiuserchat-addinvitationlistener-not-being-called

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