android中ip和hosts地址的获取
来源:互联网 发布:产品网络营销策划书 编辑:程序博客网 时间:2024/05/08 07:55
public static String getMyIP() { 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() && inetAddress instanceof Inet4Address) { return inetAddress.getHostAddress().toString(); } } } } catch (Exception e) { } return ""; } public static String getDNSIP(String host) { InetAddress x; try { x = InetAddress.getByName(host); String ip = x.getHostAddress();//得到字符串形式的ip地址 return ip; } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; }暂时没有看源码,有时间补上
0 0
- android中ip和hosts地址的获取
- Android中获取本机ip地址和MAC地址
- Android中获取本机ip地址和MAC地址
- android中获取ip地址和mac地址
- Android开发中获取本机Mac地址和IP地址的方法
- android 获取ip地址和mac地址的多种方式
- android获取IP地址和MAC地址的方法
- android获取Mac地址和IP地址
- android获取Mac地址和IP地址
- Android 获取Mac地址和IP地址
- 如何在android 中获取Wifi设备的IP地址
- Android中获取有线网络的IP地址
- 获取android模拟器的IP地址和访问网络
- android 获取设备的IP和Mac地址
- android开发 获取WIFI和有线的IP地址
- android获取本机的IP地址和mac物理地址
- Android获取Ethernet、WIFI的ip和mac地址
- Android获取Ethernet、WIFI的ip和mac地址
- 微信JSSDK PHP Demo
- HTML的文本输入框、密码输入框
- 【算法,算法】Who are you?
- 一篇简绍android SQLite基础的好文章
- Swift_mutating
- android中ip和hosts地址的获取
- Android实战-初探EventBus
- 技术博客
- AndroidManifest.xml中android:label标签的使用
- MyEclipse启动Tomcat出现Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
- HttpClient 4.3超时设置
- struts2 ireport jasperReport
- python re 模块 findall 函数用法简述
- 黑马程序员--java基础日记--集合