未调用“MultiUserChat.addInvitationListener”

时间:2014-11-25 11:33:27

标签: android xmpp asmack multiuserchat

我正在开发 GroupChat 进程。我已成功发送邀请并使用PSI我已收到此邀请。但是M无法调用我自己的“ MultiUserChat.addInvitationListener ”。我做了很多这样的事,但是徒劳无功。这是我的一次尝试。

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

做“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();

}

0 个答案:

没有答案