Code example for WifiInfo

Methods: getSupplicantState

0
     */ 
    public static boolean isConnectedToInternet(Context ctx) {
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wi = wm.getConnectionInfo();
        return !((wi == null || WifiInfo.getDetailedStateOf(wi.getSupplicantState()) == NetworkInfo.DetailedState.IDLE) &&
                tm.getDataState() != TelephonyManager.DATA_CONNECTED);
    } 
} 
Contextual code suggestions in your IDE  Get Codota for Java