android 獲取本機(jī)的IP地址和mac物理地址的實(shí)現(xiàn)方法
獲取本機(jī)IP地址
public String getLocalIpAddress() { WifiManager wifiManager = (WifiManager) getSystemService(android.content.Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); try { return InetAddress.getByName(String.format("%d.%d.%d.%d", (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff))).toString(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
獲取本機(jī)的物理地址
public String getLocalMacAddress() { WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); return info.getMacAddress(); }
以上就是Android 獲取手機(jī) IP和MAC地址的方法,希望能幫助到讀者,謝謝大家對(duì)本站的支持!
- Android開(kāi)發(fā)獲取手機(jī)內(nèi)網(wǎng)IP地址與外網(wǎng)IP地址的詳細(xì)方法與源碼實(shí)例
- Android獲得設(shè)備狀態(tài)信息、Mac地址、IP地址的方法
- Android中使用adb命令通過(guò)IP地址連接手機(jī)
- Android實(shí)現(xiàn)IP地址輸入框的方法示例代碼
- Android開(kāi)發(fā)實(shí)現(xiàn)在Wifi下獲取本地IP地址的方法
- Android 判斷ip地址合法實(shí)現(xiàn)代碼
- Android 獲取IP地址的實(shí)現(xiàn)方法
- android實(shí)現(xiàn)獲取有線和無(wú)線Ip地址的方法
- Android手機(jī)獲取IP地址的兩種方法
- Android開(kāi)發(fā)準(zhǔn)確獲取手機(jī)IP地址的兩種方式
相關(guān)文章
Android Drawable必備知識(shí)小結(jié)
這篇文章主要為大家詳細(xì)了Android Drawable必備基礎(chǔ)知識(shí) ,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-10-10Android使用Messenger實(shí)現(xiàn)service與activity交互
這篇文章主要介紹了android使用Messenger實(shí)現(xiàn)service與activity交互的相關(guān)資料,需要的朋友可以參考下2016-06-06android多開(kāi)器解析與檢測(cè)實(shí)現(xiàn)方法示例
最近有業(yè)務(wù)上的要求,要求app在本地進(jìn)行諸如軟件多開(kāi)、hook框架、模擬器等安全檢測(cè),防止作弊行為,下面這篇文章主要給大家介紹了關(guān)于android多開(kāi)器解析與檢測(cè)實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2021-08-08Android開(kāi)發(fā)簡(jiǎn)易音樂(lè)播放器
這篇文章主要為大家詳細(xì)介紹了Android開(kāi)發(fā)簡(jiǎn)易音樂(lè)播放器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-12-12Android 自定義圖片地圖坐標(biāo)功能的實(shí)現(xiàn)
最近項(xiàng)目要求實(shí)現(xiàn)一個(gè)在自定義地圖圖片上添加坐標(biāo)信息的功能,類(lèi)似于在圖片做標(biāo)注的功能,這種功能糾結(jié)該如何實(shí)現(xiàn)呢?下面小編通過(guò)實(shí)例代碼給大家介紹Android 自定義地圖的實(shí)現(xiàn),需要的朋友參考下吧2021-07-07Android HTTP網(wǎng)絡(luò)請(qǐng)求的異步實(shí)現(xiàn)
這篇文章主要介紹了Android HTTP網(wǎng)絡(luò)請(qǐng)求的異步實(shí)現(xiàn),感興趣的小伙伴們可以參考一下2016-07-07Android ViewPager實(shí)現(xiàn)輪播圖效果
這篇文章主要為大家詳細(xì)介紹了Android ViewPager實(shí)現(xiàn)輪播圖效果的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02