Today I’m going to share simple chat application that is based on xmpp protocol.
i know that you have lots of question about xmpp , so simply i’m start with some definition or basic question.
# what is xmpp ?
xmpp is the extensible messaging and presence protocol, a set of open technologies for instant messaging,presence,multi-party chat, voice and video calls, collaboration, lightweight middleware, content syndication,and generalized routing of xml data.
XMPP was originally developed in the Jabber open-source community to provide an open, decentralized alternative to the closed instant messaging services at that time. click here for more detail.
# Why xmpp?
#Open standard – its gives you the choice and control about how you access your data and service.
#multi platform support – you can create chat application for the multiple platform over the xmpp protocol.
# xmpp implementation :
For the xmpp chat application we have to implement chat client and configure server. firstly we are talking about chat client then we going to implement server configuration.
The following assumes that you have already basic knowledge in Android development with android studio.
2.Smack 4.1 library (smack 4.1 supporting android for previous version we need to implement asmack library).
step 1 > Create a project in android studio(File -> New Project(add Application name,project location) -> check phone and teblet and select minimum sdk -> select activity type -> define activity name ->finish) for more detail how to manage a project in android studio click here
add library detail in build.gradle file as below.
step 2 > after adding library into project , now connect to openfire server and login as user.
above this code example i have disable ssl and DIGEST-MD5 . According to your need you can enable it.
if you want to create user through your application then use AccountManager classto do it as for exp :
step 3 > after successfully connected to chat server now create a chat with another user and receive there message.
Above this code i’ve created ‘doChat’ method where we need to pass userId(userId withwhome we want to chat) and implement ChatMessageListner to recive user message.
I hope a tutorial is helpful.
Thanks for reading 🙂Follow @nikeshpathak
3 thoughts on “Chat application over xmpp protocol”
Ahh a really nice and helpful post , keep it up bro 🙂
hi, tnx alot for the guide … . but I have a question. what is the IChatListener ?
I can’t find its definition
this is just a callback interface , it is not part of smack library .