Get System Wifi Ip Address : WiFi « Network « Android






Get System Wifi Ip Address

 
//package edu.umich.jezzball.net;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

class Utility
{
  static final int IP_ADDRESS_LENGTH = 32;

  public static Integer getSystemWifiIpAddress(Context context)
  {
    WifiManager wManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wInfo = wManager.getConnectionInfo();

    int ipAddress = wInfo.getIpAddress();
    if (ipAddress == 0)
      return null;
    return ipAddress;
  }
}

   
  








Related examples in the same category

1.Is Wifi service enabled by Context.WIFI_SERVICE
2.Airplane Mode and turn Wifi On
3.Allow WiFi or allow mobile
4.Is WiFi Connected