Back to project page 1040_searchlit.
The source code is released under:
GNU General Public License
If you think the Android project 1040_searchlit 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.example.build2; /* w w w . j a v a 2 s. c o m*/ import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Utils { public static boolean isNetworkAvailable(Activity activity) { ConnectivityManager connectivity = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { return false; } else { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getState() == NetworkInfo.State.CONNECTED) { return true; } } } } return false; } }