Using ConnectivityManager : ConnectivityManager « Network « Android






Using ConnectivityManager

   
import android.content.Context;
import android.net.ConnectivityManager;

class NetworkUtil {

  public static boolean CheckNetwork(Context context) {
    boolean flag = false;         
    ConnectivityManager cwjManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cwjManager.getActiveNetworkInfo() != null)            
      flag = cwjManager.getActiveNetworkInfo().isAvailable();
    return flag;
  }
}

   
    
    
  








Related examples in the same category