code: protected static boolean isConnected(Context ctx) {
          ConnectivityManager connectivityManager =
              (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
          return activeNetworkInfo != null && activeNetworkInfo.isConnected();
      }
docs: Check whether the application has internet access at a point in time.
  
  @param ctx Android application context
  @return true if the application has internet access