Android Network State Check isNetworkAvailable(Context context)

Here you can find the source of isNetworkAvailable(Context context)

Description

is Network Available

Declaration

public static boolean isNetworkAvailable(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isNetworkAvailable(Context context) {
        try {/*from w  w  w  . j a  v  a  2 s  . c  o m*/
            ConnectivityManager connectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo activeNetworkInfo = connectivityManager
                    .getActiveNetworkInfo();
            return activeNetworkInfo != null;
        } catch (Exception e) {

        }

        return false;
    }
}

Related

  1. isMobileOnline(Context context)
  2. isInternetReachable(Context context)
  3. isHightBandwidthConnection(Context context)
  4. isConnectionFast(int type, int subType)
  5. isNetAvailable(Context context)
  6. isNetworkAvailable(Context context)
  7. isNetworkAvailable(Context context)
  8. isNetworkAvailable(Context paramContext)
  9. isNetworkAvailable(Context context)