I am new to Android programming.I have completed the basics though and wish to learn XMPP for making a chat application on Android. I've gone through tutorials, but have not got the way to use a custom pc as server for the application.I want to use my laptop as a server for sending messages between 2 android devices.My laptop should be able to recieve and direct the messages between the two.Can anyone please help me get started?
Asked
Active
Viewed 3.0k times
1 Answers
33
First of all, you need to install in your laptop a XMPP server. Here are a list of available ones. People used to say Openfire is easy to install and configure, but to production purposes Ejabberd (linux and mac only) seems to be more robust.
To develop your app, you can use Smack, which is large well documented, with code snapshots to connect to a server, create a chat, send and receive messages etc.

Flow
- 23,572
- 15
- 99
- 156

Plinio.Santos
- 1,709
- 24
- 31
-
5I went through the link but still havent understood what would be my HOST,PORT and SERVICE for the application.Sorry for such a question but I am just a beginner and 14 yrs old and havent got it. – user3419596 Mar 20 '14 at 11:42
-
1HOST is the domain of your XMPP server. You can use the server IP address here. The default XMPP server port to listen for clients is 5222: Try using it. SERVICE is the name you set to your XMPP server. – Plinio.Santos Mar 20 '14 at 14:47
-
@Plinio.Santos To use aSmack, I will have to add the jar files under the `libs` folder to my Android Project's lib folder, correct? – An SO User Nov 16 '14 at 17:54
-
@LittleChild Absolutely! – Plinio.Santos Nov 17 '14 at 00:04
-
@Plinio.Santos The new Smack 4.1 will run natively on Android. The instructions, however, do not show how to use that in Eclipse. If you could update your answer then that would be great! :) – An SO User Nov 17 '14 at 04:12
-
2@LittleChild Download the smack library package from (http://www.igniterealtime.org/downloads). There you will find a lot of java libraries. The most important is smack-core. You should copy smack-core-X.X.X.jar to `libs` folder within your project and refresh - right click at project folder and Refresh, or just press F5. The other java libraries will enable more capabilities to your app. A full description can be read in html files in `releasedocs` folder. – Plinio.Santos Nov 17 '14 at 22:31
-
I'm also trying to do the exact same thing, now according to https://developer.android.com/google/gcm/ccs.html#implement it says I can use python (wich I would preffer since I at least have a little experience with it). What I still can't understand is how/where you put the code? or the compiled result? I guess it's meant to go on the server... But how you do that? I already installed an openfire server on a laptop I have in the same network, what is the next step to take? – Artemio Ramirez Nov 20 '14 at 06:47
-
@ArtemioRamirez The article you sent us says how to implement a XMPP server in order to mediate the communication between your app (client side) and Google Cloud Messaging. Realize that the OP was looking for an architecture which does not include GCM. In addiction I have no acknowledgement with GCM. Sorry... Once you Openfire is up, you should create an android app and copy the Smack libraries to your project's `libs` folder. Then you will be able to use Smack API to connect to a server and send messages to any another XMPP client. – Plinio.Santos Nov 20 '14 at 14:10
-
@Plinio.Santos ok, sry for being newbish on this but I've never had to deal with a server of any kind before. So if I want the server to be able to send ie: notifications to the clients, what would be the next step? is the GCM required? – Artemio Ramirez Nov 20 '14 at 20:54
-
1@ArtemioRamirez No, it's not. As next step, I would suggest you to use a XMPP client such as [Pidgin](http://pidgin.im/) and test you Openfire (XMPP server) setup. Make sure to have an administrator account in your XMPP server and use this adm account to login with Pidgin. Once you have success, you're ready do go and develop the android application. – Plinio.Santos Nov 20 '14 at 22:05
-
@Plinio.Santos as I see it, openfire is a server with IM functionality, but if that's not the functionality I want, then I have to code my own XMPP server. How do I code my own XMPP server? Thats why I tought I'm meant to use GCM, because instant messaging is not the kind of communication I'm trying to achieve. – Artemio Ramirez Nov 20 '14 at 22:20
-
@ArtemioRamirez I'm a bit confused. In order to use XMPP capabilities, your solution has to fit the 'IM-pattern' with clients sending and receiving messages. I used this model once to keep a large range of devices content aware, taking use of push advantages. The XMPP server will act as a proxy, receiving messages from clients and sending them to another one, taking care of quality of service and deliverability. Write this protocal is not a simple task at all and the protocol stack is available at http://xmpp.org/protocols/jabber:server/ – Plinio.Santos Nov 20 '14 at 23:00
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/65318/discussion-between-artemio-ramirez-and-plinio-santos). – Artemio Ramirez Nov 20 '14 at 23:04
-
@Plinio.Santos I guess best thing I can do is explain what I'm trying to achieve. I want to code an app so that my clients install it and I can from a server push notifications on their devices letting them know about updates or offers they might be interested in. Not client to client communication, but server to client and client to server. – Artemio Ramirez Nov 21 '14 at 01:36
-
@ArtemioRamirez I answered in the chat :p – Plinio.Santos Nov 21 '14 at 01:45
-
@Plinio.Santos ,ArtemioRamirez ,LittleChild How to retrieve chat history from the chat made by asmack – ManishSB Mar 13 '15 at 20:36
-
@Real_steel4819 I don't know, sorry. Some people seem to had achieved that though: http://stackoverflow.com/questions/14545057/how-to-get-openfire-chat-history-on-android-device-with-asmack – Plinio.Santos Mar 17 '15 at 16:57
-
Hey, @Plinio you should use Google GCM for that, the push notifications stuff! – Nikhil Verma Sep 27 '16 at 04:00
-
@NikhilVerma 'Should' is a very, very strong word to use. I agree that GCS has advantages but there are scenarios which you may want control over your message traffic or just a guarantee that you will not receive fees regardless of your push load, like GCS does. It's up to each one choose what will fit best. Taking my workin needs, for instance, GCM would never be an option. – Plinio.Santos Sep 28 '16 at 13:45
-
Okay, I just though that might be a option! – Nikhil Verma Sep 28 '16 at 14:55
-
Smack is currently the best bet when it comes to android chat apps using XMPP. There is a [step by step video course already available](http://www.blikoontech.com/video-courses) – musimbate Mar 14 '18 at 12:31