Here you can find the source of isNetworkConnected(Context context)
Parameter | Description |
---|---|
context | a parameter |
public static boolean isNetworkConnected(Context context)
//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()); } }