Android Context Check hasInternetConnection(Context context)

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

Description

has Internet Connection

Declaration

public static boolean hasInternetConnection(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 hasInternetConnection(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        return networkInfo != null && networkInfo.isConnectedOrConnecting();
    }/*from  w w w .  j a  va 2 s.  c om*/
}

Related

  1. hasAsymmericMasterSecret(Context context)
  2. hasConnection(Context c)
  3. hasInternetConnectivity(Context applicationContext)
  4. hasNotificationPermission(Context context)
  5. hasOtherSPAppsInstalled(Context context)
  6. hasTelephony(@Nonnull Context context)