In my chatting application I want to implement Group Chatting functionality. For the same I want to create rooms and send the invitations to my friends to join the room. Here is my code to join and invite the friend to room.
To Create the Room
//Create Room
btn_CreateRoom = (Button)findViewById(R.id.btn_usermenu_CreateRoom);
btn_CreateRoom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
try {
muc = new MultiUserChat(connection, "room1@conference.abc.com");
muc.join("Sunil","123456");
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Room Created");
}
});
btn_Invite = (Button)findViewById(R.id.btn_usermenu_InviteToRoom);
btn_Invite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
muc.invite("sunil@abc.com", "Please join this room");
}
});
}
To recieve the invitation I have implemented an Invitation Listener in my Service Class. But I am unable to receive the invitaion via notification. Wats the problem with the code.
Here is my Invitation Listener.
MultiUserChat.addInvitationListener(connection, new InvitationListener() {
@Override
public void invitationReceived(Connection arg0, String arg1, String arg2,
String arg3, String arg4, Message arg5) {
// TODO Auto-generated method stub
System.out.println("Received??");
notification("Invitation Received");
Please let me know Why I am not receiving the invitation.??
Thanks
you write this code after
xmppconnection.connect()
its work for me ..try it
We missed Thread here:
Just add below code to join group:
Hope this will help a lot.
You can try this
This might solve your problem.