Search code examples
androidchatsocketchannel

Android - How to keep connection with server for a long time


I wrote a chat application for Android using SocketChannel. It connects successfully with the server and all features work. But after a long time since I logged in (about 2-3 hours), I try to send a chat message again and it fails. In log file, SocketChannel, selector still open and connect to server, message already write successful. What's the problem? What am I missing?

Thanks in advance for your help.


Solution

  • if you want to create a Chat for android or something else with push from a server, try it with MQTT

    http://tokudu.com/2010/how-to-implement-push-notifications-for-android/

    its is a very cool thing, just take a look at it :-)