Here you can find the source of hasNetworkAccess()
public static boolean hasNetworkAccess()
//package com.java2s; //License from project: LGPL import java.net.*; public class Main { public static boolean hasNetworkAccess() { try {/*from www . j av a2 s . com*/ final InetAddress address = InetAddress.getByName("www.google.com"); return true; } catch (Throwable ignored) { } return false; } }