Monday, August 18, 2014

Implement simple Android Chat Application, server side.

It's a simple example of Chat app running on Android devices, both server and clients. One device run AndroidChatServer to wait connection from clients, other devices run AndroidChatClient to connect to the server. Any AndroidChatClient can send message to server, then server broadcast to all clients.

Thanks for the example. I found out that readUTF uses a modified UTF-16 encoding. The size of buffer your sending needs be the first byte of what your sending. Something like '123' would actually translate to { 0, 3, 0, 49, 0, 50, 0, 51 } in raw bytes ... I hope that saves someone a headache when writing a client in a different language.

Hi.i am developing an app in which i used your code for Server/Client connections...my app is getting crashed when i try to run it...in log cat the error shown was related to when i try to add Chat-Client touserList.when i use this List in my code it throws null pointer exception...please help me solve this issue

after getting connection refused errors i tried this: i shared my phone's internet (mobile data) with my tablet and then tried to connect again and this time it worked! i tried different ports and it works very well. it seems that there is a problem with my router or something that does not let me establish a connection. i hope this works for others like me.

I am not sure but I think when client disconnect from the application, Toast that writes "removed" does not seem immediately.It is seen after a new client connects and sends a message.How can i handle this? Thanks for the answers.

Thank you Eric for sharing this application. I've faced just one problem in this that the ip of the server keeps changing. Can you please tell me if u know a way to handle this frequent ip changing problem.

I am using esp8266 wifi module.Both the mobile which runs ChatServer and esp8266 are connected to same wifi. After configuring esp8266 module with ip address and port number displayed in ChatServer application, connection is established and data is also sent from esp8266 but it is not displayed on the mobile ChatServer application. Why ? Does this ChatServer application only work on ChatClient application from another mobile and not from any other devices or terminal from pc ?