2

我目前正在进行群聊,当有人邀请我时我无法收到任何通知。我正在使用服务来跟踪通知,并且我的服务类实现了邀请监听器。

    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();   
        }  
     });  

}

不正确的部分是什么??另外,我想跟踪房间里有多少人,并希望显示他们的所有名字。有什么办法可以做到吗?

4

0 回答 0