tags:

views:

32

answers:

1

I am making an application which makes use of internet.

It works fine when Wifi is availble.But when wi fi is turned of then it give me error "Address Family Not supported".

I am using NetworkInfo Class to know the status of network availble and using WifiManager to enable and manage Wi-fi connection if available

A: 

I've been using the following code to check if there is inet:

ConnectivityManager mConnectivity = (ConnectivityManager) this
                                        .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = mConnectivity.getActiveNetworkInfo();
if (info == null) {
    // No inet
}
Macarse
Thanks for guide.can i make explicit connection from my application?any idea
Rakesh Gondaliya
@rakesh-gondaliya: What you mean by "explicit connection"?
Macarse
there might be settings in mobile in which it might be the case that GPRS may be the Default connection, so if Wi-Fi is available i want to make Http connection which uses Wifi only, so that i would not be charged for the transfer of packets through GPRS. Did u get?
Rakesh Gondaliya
@rakesh-gondaliya: Yes. I am not 100% sure but I think there is only one type of connection at certain time. NetworkInfo should tell you which is available.
Macarse
@ Macarse : thanks fro your guide...I got the concept
Rakesh Gondaliya