Created
August 28, 2013 06:52
-
-
Save showsky/6362865 to your computer and use it in GitHub Desktop.
com.miiitv.box.utility
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
package com.miiitv.box.utility; | |
import android.content.Context; | |
import android.net.ConnectivityManager; | |
import android.net.DhcpInfo; | |
import android.net.wifi.WifiManager; | |
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