use of android.net.NetworkInfo in project weiciyuan by qii.
the class Utility method isGprs.
public static boolean isGprs(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
if (networkInfo.getType() != ConnectivityManager.TYPE_WIFI) {
return true;
}
}
return false;
}
use of android.net.NetworkInfo in project weiciyuan by qii.
the class Utility method isWifi.
public static boolean isWifi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
}
return false;
}
use of android.net.NetworkInfo in project weiciyuan by qii.
the class AboutFragment method buildContent.
private String buildContent() {
String network = "";
ConnectivityManager cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
network = "Wifi";
} else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
int subType = networkInfo.getSubtype();
if (subType == TelephonyManager.NETWORK_TYPE_GPRS) {
network = "GPRS";
}
}
}
return "@四次元App #四次元App反馈# " + android.os.Build.MANUFACTURER + " " + android.os.Build.MODEL + ",Android " + android.os.Build.VERSION.RELEASE + "," + network + " version:" + buildVersionInfo();
}
use of android.net.NetworkInfo in project xabber-android by redsolution.
the class NetworkManager method onNetworkChange.
public void onNetworkChange(NetworkInfo networkInfo) {
NetworkInfo active = connectivityManager.getActiveNetworkInfo();
LogManager.i(this, "Network: " + networkInfo + ", active: " + active);
Integer type;
boolean suspended;
if (active == null && this.type != null && this.type == networkInfo.getType()) {
type = getType(networkInfo);
suspended = isSuspended(networkInfo);
} else {
type = getType(active);
suspended = isSuspended(active);
}
if (this.type == type) {
if (this.suspended == suspended)
LogManager.i(this, "State does not changed.");
else if (suspended)
onSuspend();
else
onResume();
} else {
if (suspended) {
type = null;
suspended = false;
}
if (type == null)
onUnavailable();
else
onAvailable(type);
}
this.type = type;
this.suspended = suspended;
}
use of android.net.NetworkInfo in project android by cSploit.
the class Network method isWifiConnected.
public static boolean isWifiConnected(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return info != null && info.isConnected() && info.isAvailable();
}
Aggregations