Back to project page YgnTraffic.
The source code is released under:
GNU General Public License
If you think the Android project YgnTraffic 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 me.sh.ygntraffic.util; //from w w w .j av a2s . c o m import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; /** * @author yelinaung */ public class NetUtil { // Check the device is connected to the internet public static boolean isOnline(Context c) { NetworkInfo netInfo = null; try { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); netInfo = cm.getActiveNetworkInfo(); } catch (SecurityException e) { e.printStackTrace(); } return netInfo != null && netInfo.isConnectedOrConnecting(); } }