multiuserchat addinvitationlisterner不工作

时间:2013-03-13 09:48:44

标签: android xmpp smack

我目前正在进行小组聊天,当有人邀请我时,我无法收到任何通知。 我使用服务来跟踪通知,我的服务类实现了invitationlistener。

    public void onCreate() {
  //code to execute when the service is first created
    Log.d("Service", "Start myCityMessageService");
    this.receive_manager = MyCityUtils.getReceiveManager();
    this.receive_manager.registerReceivedObserver(this);       
    MultiUserChat.addInvitationListener(MyCityUtils.getChatHandler().getConnection(), this);

}
   @Override
public void invitationReceived(Connection con, final String room, final String inviter, String reason, String pass, Message msg)
{
    Log.i("Invite","Here it is");
    handler.post(new Runnable() {  
        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which){
                case DialogInterface.BUTTON_POSITIVE:
                    //Yes button clicked
                    Intent intent = new Intent(getApplicationContext(), GroupChatMessageScreenActivity.class);

                    startActivity(intent);
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    //No button clicked
                    MultiUserChat.decline(MyCityUtils.getChatHandler().getConnection(), room, inviter, "Busy");
                    break;
                }
            }
        };
        @Override  
        public void run() {  
            AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
            builder.setMessage(inviter + "invite you to a group chat.\nWant to Join?")
                .setPositiveButton("Yes", dialogClickListener)
                .setNegativeButton("No", dialogClickListener).show();   
        }  
     });  

}

错误的部分是什么? 此外,我想跟踪房间里有多少人,并想要显示他们的所有名字。有什么方法可以做到吗?

0 个答案:

没有答案