public class NetworkState {
private static ConnectivityManager ctm;
public NetworkState() {
}
public static boolean isOk(Activity act) {
Context ctx = act.getApplicationContext();
ctm = (ConnectivityManager) ctx
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo infos = ctm.getActiveNetworkInfo();
if (infos != null && infos.isAvailable()) {
return true;
}
return false;
}
public static String getNetType(Activity act) {
if (isOk(act)) {
String netType = ctm.getActiveNetworkInfo().getTypeName()
.toLowerCase();
return netType;
}
return null;
}
}