Hi can someone give me a example on how to achieve this ??
The whole chat system should be separated from UI. And UI should simply "bind" to the chat "stream" to send/receive data. This would let you to switch between chats and these "invisible" chats could still receive messages from your parties. Also you want your app to be able to receive messages even when app is "in background" so there's not really any other choice. Not to mention that approach would help you building i.e. UI for tablet with more than one visible chat.