title: Reconnect to the internet automatically
body: <p>I'm developing an Android chat application. On startup the application launches a service. The service connects to the chat server. If for some reason the connection goes down, the user can click a button and the reconnect() function gets called.</p>
  
  <p>The application runs on a mobile device. The application connects to the Internet via Wi-Fi. If the user, walking with his phone, goes out of the Wi-Fi coverage area, the connection goes down. I want my application to automatically try to reconnect to the Internet in such cases. What's the best way to do this in your opinion?</p>