Friday 8 February 2013

Check Internet connection + android

public static boolean CheckNetwork(Context mContext)
 {

        ConnectivityManager connectivity = (ConnectivityManager) mContext
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netinfo = connectivity.getActiveNetworkInfo();
        if (netinfo != null && netinfo.isConnected() == true) {

            return true;
        } else {

            return false;
        }

    }

Press control + shift + O for importing required library

No comments:

Post a Comment