Search in sources :

Example 6 with DhcpInfo

use of android.net.DhcpInfo in project GwellDemo by dxsdyhm.

the class Util method getIntentAddress.

public static InetAddress getIntentAddress(Context mContext) throws IOException {
    WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    DhcpInfo dhcp = wifiManager.getDhcpInfo();
    int broadcast = (dhcp.ipAddress & dhcp.netmask) | ~dhcp.netmask;
    byte[] quads = new byte[4];
    for (int k = 0; k < 4; k++) quads[k] = (byte) ((broadcast >> k * 8) & 0xFF);
    return InetAddress.getByAddress(quads);
}
Also used : WifiManager(android.net.wifi.WifiManager) DhcpInfo(android.net.DhcpInfo)

Aggregations

DhcpInfo (android.net.DhcpInfo)6 WifiInfo (android.net.wifi.WifiInfo)3 Context (android.content.Context)1 DhcpResults (android.net.DhcpResults)1 LinkAddress (android.net.LinkAddress)1 NetworkInfo (android.net.NetworkInfo)1 RouteInfo (android.net.RouteInfo)1 ScanResult (android.net.wifi.ScanResult)1 WifiConfiguration (android.net.wifi.WifiConfiguration)1 WifiManager (android.net.wifi.WifiManager)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 ListPreference (android.support.v7.preference.ListPreference)1 Preference (android.support.v7.preference.Preference)1 AppListSwitchPreference (com.android.settings.AppListSwitchPreference)1 DobbyEvent (com.inceptai.dobby.eventbus.DobbyEvent)1 DobbyWifiInfo (com.inceptai.dobby.model.DobbyWifiInfo)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Inet4Address (java.net.Inet4Address)1 InetAddress (java.net.InetAddress)1