Skip to content

Instantly share code, notes, and snippets.

@showsky
Created August 28, 2013 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save showsky/6362865 to your computer and use it in GitHub Desktop.
Save showsky/6362865 to your computer and use it in GitHub Desktop.
com.miiitv.box.utility
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