Back to project page AURHelperDroid.
The source code is released under:
Apache License
If you think the Android project AURHelperDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.stomachion.aurhelperdroid.network; /*from w w w . ja v a2 s . c om*/ import android.content.Context; import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.telephony.TelephonyManager; /** * User: Pedro Veloso */ public final class InternetState { /** * @param ctx Context of the running activity/service * @return True if device is connected to the Internet */ 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); } }