rodamora
1/20/2016 - 10:37 AM

Function to check if there is network connectivity

Function to check if there is network connectivity

public boolean isNetWorkAvailable(Context context){
    ConnectivityManager connectivityManager =
        (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if(networkInfo != null && networkInfo.isConnected()){
      return true;
    }
    return false;
}