[Java]
<SPAN style = "COLOR: #993300"> Connected via WIFI
WifiManager wifiManager = (WifiManager) getSystemService (WIFI_SERVICE );
WifiInfo wifiInfo = wifiManager. getConnectionInfo ();
Int ipAddress = wifiInfo. getIpAddress (); </SPAN>
Connected via WIFI
WifiManager wifiManager = (WifiManager) getSystemService (WIFI_SERVICE );
WifiInfo wifiInfo = wifiManager. getConnectionInfo ();
Int ipAddress = wifiInfo. getIpAddress ();
[Java]
<SPAN style = "COLOR: #993300"> Connected via GPRS
Public String getLocalIpAddress ()
{
Try
{
For (Enumeration <NetworkInterface> en = NetworkInterface. getNetworkInterfaces (); en. hasMoreElements ();)
{
NetworkInterface intf = en. nextElement ();
For (Enumeration <InetAddress> enumIpAddr =
Intf. getInetAddresses (); enumIpAddr. hasMoreElements ();)
{
InetAddress inetAddress = enumIpAddr. nextElement ();
If (! InetAddress. isLoopbackAddress ())
{
Return inetAddress. getHostAddress (). toString
();
}
}
}
}
Catch (SocketException ex)
{
Log. e (S. TAG, ex. toString ());
}
Return null;
} </SPAN>
Connected via GPRS
Public String getLocalIpAddress ()
{
Try
{
For (Enumeration <NetworkInterface> en = NetworkInterface. getNetworkInterfaces (); en. hasMoreElements ();)
{
NetworkInterface intf = en. nextElement ();
For (Enumeration <InetAddress> enumIpAddr =
Intf. getInetAddresses (); enumIpAddr. hasMoreElements ();)
{
InetAddress inetAddress = enumIpAddr. nextElement ();
If (! InetAddress. isLoopbackAddress ())
{
Return inetAddress. getHostAddress (). toString
();
}
}
}
}
Catch (SocketException ex)
{
Log. e (S. TAG, ex. toString ());
}
Return null;
}