-
-
Save osama-raddad/7dd6687b877065e38a1d to your computer and use it in GitHub Desktop.
Network Info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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