Android Network State Check isConnected(final Activity act)

Here you can find the source of isConnected(final Activity act)

Description

is Connected

License

Open Source License

Declaration

public static boolean isConnected(final Activity act) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isConnected(final Activity act) {
        final ConnectivityManager connMgr = (ConnectivityManager) act
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        final NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

        if (networkInfo != null && networkInfo.isConnected()) {
            return true;
        }//from  ww w.  j a  v  a  2 s .c  om

        return false;
    }
}

Related

  1. loadImageFromNetwork(String photoUrl)
  2. IsInternetReachable()
  3. setMobileDataEnabled(Activity a, Context context, boolean enabled)
  4. isNetworkAvailable(Activity mainActivity)
  5. isDeviceOnline(Activity activity)
  6. isOnline(Activity activity)
  7. CheckInternet(Activity a)
  8. checkInternetConnection(Context context)