First you have to define "connected to the internet".  You might be
connected to the local router, eg, but it might not have a route out.
You might even have a connection to a large network (eg, a
university), but not be able to get past some firewall to the "rest of
the world".

On Aug 20, 2:33 pm, tarek attia <[email protected]> wrote:
> Hi all,
>
> In my application I must use the internet connection ,so I check it first
> before I open an URL connection using this :-
>
> public boolean IsConnectedToNetwork(ConnectivityManager conManager)
>  {
>       NetworkInfo allNetworkInfo = conManager.getActiveNetworkInfo();
>       NetworkInfo currNetworkInfo;
>       boolean anythingConnected = false;
>     for (int i = 0; i < allNetworkInfo.length; i++)
>     {
>        currNetworkInfo = allNetworkInfo[i];
>
>        if (currNetworkInfo.getState() == NetworkInfo.State.CONNECTED)
>             {
>        anythingConnected=true;
>             }
>
>     }
>
>      return anythingConnected;
>  }
>
> However this code runs well when I connected to either the operator internet
> Or to a Wi-fi network .
>
> But when I'm connected to the operator but without credit and no internet
> the mobile also sees it as there's internet,or even connected to a Wi-fi
> network but without internet gateway it also sees as if it's connected to
> the internet
>
> Any Idea how can ensure that I'm connected to the internet ??
>
> --
>
> tarek

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to