Android Network State Check onNetwork(Context context)

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

Description

on Network

Declaration

public static boolean onNetwork(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 onNetwork(Context context) {

        final ConnectivityManager conMgr = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
        if (activeNetwork != null && activeNetwork.isConnected()) {
            return true;
        } else {/*from  w w  w .j av a2  s  .  c o  m*/
            return false;
        }
    }
}

Related

  1. isNetworkConnected(Context context)
  2. isMobileConnected(Context context)
  3. isNetworkConnected(Context context)
  4. isNetworkAvailable(Context context)
  5. isNetworkConnected(Context context)
  6. haveNetworkConnection(Context context)
  7. isNetworkConnected(Context context)
  8. isNetworkEnabled(Context context)
  9. check3GNetwork(Context context)