package net.king.androidterminal.util;

import java.net.InetAddress;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

public class WifiUtils {
    
    private static WifiUtils wifiUtils;
    private Context context;
    
    private WifiUtils(Context context) {
        this.context = context;
    }
    
    public static WifiUtils getInstance(Context context){
        if (wifiUtils == null) {
            wifiUtils = new WifiUtils(context);
        } 
        return wifiUtils;
    }
    
    /**
     * ȡֻIPַ
     * wifi
     */
    public String getIpAddress() {
        int result = 0;
        WifiManager wifiManager =(WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        result = wifiInfo.getIpAddress();
        return intToIp(result);
    }
    
    private String intToIp(int i) { 
        return (i & 0xFF ) + "." + 
        ((i >> 8 ) & 0xFF) + "." + 
        ((i >> 16 ) & 0xFF) + "." + 
        ( i >> 24 & 0xFF) ; 
    } 
}



@@ -561,21 +561,24 @@
   * 
-%C8%A1%D6%BBIP%D6%B7
+%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BAIP%E5%9C%B0%E5%9D%80
 %0A     * 
 wifi
@@ -573,16 +573,20 @@
 %0A     * 
+%E5%BF%85%E9%A1%BB%E8%BF%9E%E4%B8%8A
 wifi%0A   
@@ -886,24 +886,99 @@
 %0A    %7D%0A    %0A
+    /**%0A     * %E7%9B%B4%E6%8E%A5%E8%8E%B7%E5%8F%96%E7%9A%84IP%E5%9C%B0%E5%9D%80%E6%98%AF%E4%B8%80%E4%B8%AA4%E5%AD%97%E8%8A%82%E7%9A%84%E6%95%B4%E6%95%B0%0A     * %E9%9C%80%E8%A6%81%E6%89%8B%E5%8A%A8%E5%A4%84%E7%90%86%E6%88%90%E5%B8%B8%E8%A7%81%E7%9A%84192.168.1.155%E5%BD%A2%E5%BC%8F%0A     */%0A
     private 

Update WifiUtils.java