Android Network State Check isNetworkAvailable(Activity mainActivity)

Here you can find the source of isNetworkAvailable(Activity mainActivity)

Description

is Network Available

Declaration

public static boolean isNetworkAvailable(Activity mainActivity) 

Method Source Code

//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isNetworkAvailable(Activity mainActivity) {
        ConnectivityManager connectivityManager = (ConnectivityManager) mainActivity
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager
                .getActiveNetworkInfo();
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();
    }/*from w  w  w. j av a  2  s.  com*/
}

Related

  1. isLocationEnabledNetwork(Context c)
  2. isOpenNetwork(Context context)
  3. loadImageFromNetwork(String photoUrl)
  4. IsInternetReachable()
  5. setMobileDataEnabled(Activity a, Context context, boolean enabled)
  6. isDeviceOnline(Activity activity)
  7. isConnected(final Activity act)
  8. isOnline(Activity activity)
  9. CheckInternet(Activity a)