From http://stackoverflow.com/questions/4238921/android-detect-whether-there-is-an-internet-connection-available/4239410#4239410