Personal Blog of Mustafa Basgun

Check to See If Android Device is Connected to Internet by Using isReachable Method

with one comment

If you need to check to see if the Android device is connected to the internet, an alternative (and simple but limited) way to using the ConnectivityManager class can be calling the isReachable method. Here is a sample function:

mustafa-basgun-blog-android-check-internet-connectivity-1

Advertisements

Written by Mustafa Basgun

October 11, 2010 at 11:23 AM

One Response

Subscribe to comments with RSS.

  1. The problem with that is those nasty WiFi networks that redirect all your web access to a login web page. This code will resolve http://www.google.com to the IP of their login server (like 1.1.1.1) and will falsely claim that you are connected. It is much safer to double-check by downloading the http://www.google.com page and checking if it contains some static string (that does not change with locale or their daily upgrades).

    Aigarius

    January 20, 2011 at 12:09 PM


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: