Skip to content

Instantly share code, notes, and snippets.

@osama-raddad
Forked from showsky/Network.java
Last active January 7, 2016 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osama-raddad/7dd6687b877065e38a1d to your computer and use it in GitHub Desktop.
Save osama-raddad/7dd6687b877065e38a1d to your computer and use it in GitHub Desktop.
Network Info
public class Network {
public static DhcpInfo getNetworkInfo(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
android.net.NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
switch (activeNetworkInfo.getType()) {
case ConnectivityManager.TYPE_ETHERNET:
return null;
case ConnectivityManager.TYPE_WIFI:
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
return wifi.getDhcpInfo();
default:
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment