首先設定許可權:
/**
* if (intf.getname().tolowercase().equals("eth0") || intf.getname().tolowercase().equals("wlan0"))
* 表示:僅過濾無線和有線的ip. networkinte***ce是有很多的名稱的
* 比如sim0,remt1.....等等.我不需要用到就直接過濾了
* * if (!ipaddress.contains("::"))
* 表示: 過濾掉ipv6的位址.不管無線還是有線 都有這個位址,
* 我這邊顯示位址大體是:fe80::288:88ff:fe00:1%eth0 fe80::ee17:2fff:fece:c0b4%wlan0
* 一般都是出現在第一次迴圈.第二次迴圈就是真正的ipv4的位址.
* * @return
* @throws socketexception
*/public string getipaddress() throws socketexception }}
} else
}} catch (exception e)
// final contentresolver mcontentresolver = getcontentresolver();
// settings.system.putint( mcontentresolver,
// settings.system.wifi_use_static_ip, 1);
// settings.system.putstring( mcontentresolver,
// settings.system.wifi_static_ip, "你的ip位址");
return ipaddress;
}public string getaddress()
wifiinfo wifiinfo = wifimanager.getconnectioninfo();
dhcpinfo info = wifimanager.getdhcpinfo();
int ipaddress = wifiinfo.getipaddress();
int ii = info.ipaddress;
// return inttoip(ipaddress);
return ipaddress + " dhcp: " + ii;
}private string inttoip(int i)
}
Android開發 通過Wifi獲取經緯度
size medium 第一步 獲取wifi管理物件 ok.到此就可以獲取經緯度了。當然如果你所在的wifi從來沒有通過其他裝置定位過,及google資料庫中沒有該wifi熱點的位置資訊,那就獲取不到經緯度了。wifimanager mainwifi wifimanager getsystemser...
android之wifi開發(一)
wifi就是一種無線聯網技術,常見的是使用無線路由器。那麼在這個無線路由器的訊號覆蓋的範圍內都可以採用wifi連線的方式進行聯網。如果無線路由器連線了乙個adsl線路或其他的聯網線路,則又被稱為 熱點 在android中對wifi操作,android本身提供了一些有用的包,在android.net....
android之wifi開發(一)
wifi就是一種無線聯網技術,常見的是使用無線路由器。那麼在這個無線路由器的訊號覆蓋的範圍內都可以採用wifi連線的方式進行聯網。如果無線路由器連線了乙個adsl線路或其他的聯網線路,則又被稱為 熱點 在android中對wifi操作,android本身提供了一些有用的包,在android.net....