編輯:關於Android編程
[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;
}
在Android開發當中,在界面上彈出一個Dialog對話框使我們經常需要做的,本篇隨筆將詳細的講解Dialog對話框這個概念,包括定義不同樣式的對話框。一、Dialog
直接上代碼: private void setDialog(){ View view = getLayoutInflater().inflate(R.
快速自動更新Android Studio版本在開發過程中,有些時候總是會報一些Android Studio vesion 版本低,要求升級之類的錯誤,然而大家又會嫌麻煩去
(1)使用數據庫mysql,腳本語言如下: /* 用戶表*/ CREATE TABLE `usertbl` ( `id` int(11) NOT NULL AUTO_