Wednesday, 4 April 2012

Checking for Internet availability in Android.

public Boolean isNetAvailable(Context con)  {

            ConnectivityManager connectivityManager = (ConnectivityManager)      
            NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            NetworkInfo mobileInfo =
            if (wifiInfo.isConnected() || mobileInfo.isConnected()) {
                return true;
        catch(Exception e){
        return false;
    and also add these permissions in manifest.xml

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


  1. Hi Rajareaddy ,

    You have posted answer on my stackoverflow profile ( , and i have tried it but still not able to get json responce from server. Please help me
    post your email id, i will send you full code and then let me know where i have made mistake.
    Plz reply ASAP.

  2. plz check your mail, i am really thankfull to you

  3. Hey , I am working on an android xmpp client , I almost finish facebook and gmail , i saw your post in stackoverflow about other service providers such as yahoo and windows live . what did u find ?