Back to project page AndroidLibraryProject.
The source code is released under:
Apache License
If you think the Android project AndroidLibraryProject 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.contextawareframework.probe; /* w w w .j a v a 2 s. c o m*/ import android.content.Context; import android.net.ConnectivityManager; public class WfiProbe { /** * Checks whether the network is available on Android device. * If the network signal is very low, it will be evaluated as NOT available. * This routine will check both MOBILE and WIFI signal. * If both of them are in disable status, <code>false</code> will be return absolutely. * </p> * Return <code>true</code> if the network is available. Otherwise, return <code>false</code>. * </p> * * @param ctx Context. * * @return <code>True</code> : the network is available.</br> * <code>False</code>: the network is NOT available. */ //in if condition || connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected() To check if network is available or not public static boolean isNetworkAvailable(Context ctx) { ConnectivityManager connMgr = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE); if(connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected() ){ return true; } return false; } }