Android Network State Check isNetworkConnected(Context context)

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

Description

Check if network exists and determine if it has Internet connectivity

Parameter

Parameter Description
context a parameter

Return

true if connection is ok

Declaration

public static boolean isNetworkConnected(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

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

public class Main {
    /**//from   www  .j a  v a 2  s  .  c  o  m
     * Check if network exists and determine if it has Internet connectivity
     * 
     * @param context
     * @return true if connection is ok
     */
    public static boolean isNetworkConnected(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        return (ni != null && ni.isConnected());
    }
}

Related

  1. isNetworkConnected(Context context)
  2. isNetworkAvailable(Context context)
  3. isNetworkConnected(Context context)
  4. onNetwork(Context context)
  5. haveNetworkConnection(Context context)
  6. isNetworkEnabled(Context context)
  7. check3GNetwork(Context context)
  8. IsNetworkConnected(Context context)
  9. isNetworkAvailableExt(Context paramContext)