Chinaunix首页 | 论坛 | 博客
  • 博客访问: 327719
  • 博文数量: 90
  • 博客积分: 1585
  • 博客等级: 上尉
  • 技术积分: 964
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-26 18:33
文章分类

全部博文(90)

文章存档

2011年(10)

2010年(80)

我的朋友

分类: 嵌入式

2010-11-11 15:17:27

  1. public String getLocalIpAddress() {  
  2.     try {  
  3.         for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {  
  4.             NetworkInterface intf = en.nextElement();  
  5.             for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {  
  6.                 InetAddress inetAddress = enumIpAddr.nextElement();  
  7.                 if (!inetAddress.isLoopbackAddress()) {  
  8.                     return inetAddress.getHostAddress().toString();  
  9.                 }  
  10.             }  
  11.         }  
  12.     } catch (SocketException ex) {  
  13.         Log.e(LOG_TAG, ex.toString());  
  14.     }  
  15.     return null;  

阅读(1043) | 评论(0) | 转发(0) |
0

上一篇:动态增加TextView

下一篇:面试题1

给主人留下些什么吧!~~